mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
mm/ksm: initialize the addr only once in collect_procs_ksm
Patch series "KSM: use linear_page_index in collect_procs_ksm()", v2.
In collect_procs_ksm() which is used to collect processes when the error
hit an ksm page, there is the same issue with rmap_walk_ksm (see the
previous discussion at [1]). So we apply the similar logic changes to the
collect_procs_ksm().
The patch [1/2] move the initializaion of addr from the position inside
loop to the position before the loop, since the variable will not change
in the loop.
The patch [2/2] optimize collect_procs_ksm by passing a suitable page
offset range to the anon_vma_interval_tree_foreach loop to reduce
ineffective checks.
This patch (of 2):
Similar to 318d87b8fa ("ksm: initialize the addr only once in
rmap_walk_ksm"), only initialize the addr once in rmap_walk_ksm because
the addr variable doesn't change across iterations.
Link: https://lore.kernel.org/20260709173212190rZdwynySRyLr9EtPuXBRU@zte.com.cn
Link: https://lore.kernel.org/all/20260703162253688u8Str9eFLR8TGCmo7nIOF@zte.com.cn/ [1]
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
ef79e0f5e3
commit
887311e5cd
3
mm/ksm.c
3
mm/ksm.c
|
|
@ -3289,7 +3289,7 @@ void collect_procs_ksm(const struct folio *folio, const struct page *page,
|
|||
rcu_read_lock();
|
||||
for_each_process(tsk) {
|
||||
struct anon_vma_chain *vmac;
|
||||
unsigned long addr;
|
||||
const unsigned long addr = rmap_item->address & PAGE_MASK;
|
||||
struct task_struct *t =
|
||||
task_early_kill(tsk, force_early);
|
||||
if (!t)
|
||||
|
|
@ -3299,7 +3299,6 @@ void collect_procs_ksm(const struct folio *folio, const struct page *page,
|
|||
{
|
||||
vma = vmac->vma;
|
||||
if (vma->vm_mm == t->mm) {
|
||||
addr = rmap_item->address & PAGE_MASK;
|
||||
add_to_kill_ksm(t, page, vma, to_kill,
|
||||
addr);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user