linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* cluster_alloc_swap_entry() may change per-cpu cluster of another CPU randomly
@ 2024-10-24  3:25 Huang, Ying
  2024-10-24  3:50 ` Kairui Song
  0 siblings, 1 reply; 8+ messages in thread
From: Huang, Ying @ 2024-10-24  3:25 UTC (permalink / raw)
  To: Kairui Song; +Cc: linux-mm

Hi, Kairui,

When reading new swap cluster allocation code.  Sorry, I didn't find
time to review your patch at the first place.  I found that in
cluster_alloc_swap_entry(), the following code path is possible,

  cluster = this_cpu_ptr(si->percpu_cluster);
  offset = alloc_swap_scan_cluster();
    ...
      spin_unlock(&ci->lock);
      spin_unlock(&si->lock);
      /* migrate to another cpu */
      spin_lock(&ci->lock);
      spin_lock(&si->lock);
  cluster->next[order] = offset;

That is, the per cpu cluster of a CPU may be changed on another CPU.  I
guess that this will not cause some functionality issue.  However, this
makes code harder to be reasoned.  Is it possible to avoid unlock before
changing per cpu cluster?  Or, give up updating per cpu cluster if we
need to unlock.

--
Best Regards,
Huang, Ying


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-06  5:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-24  3:25 cluster_alloc_swap_entry() may change per-cpu cluster of another CPU randomly Huang, Ying
2024-10-24  3:50 ` Kairui Song
2024-10-24  3:54   ` Kairui Song
2024-10-25  5:52   ` Huang, Ying
2024-11-03 17:11     ` Kairui Song
2024-11-04  3:02       ` Huang, Ying
2024-11-05 18:04         ` Kairui Song
2024-11-06  5:24           ` Huang, Ying

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox