On 12/31/24 at 01:46am, Kairui Song wrote: ......snip.. > + > +/* > + * Must be called after allocation, moves the cluster to full or frag list. > + * Note: allocation doesn't acquire si lock, and may drop the ci lock for > + * reclaim, so the cluster could be any where when called. > + */ > +static void relocate_cluster(struct swap_info_struct *si, > + struct swap_cluster_info *ci) > +{ > + lockdep_assert_held(&ci->lock); > + > + /* Discard cluster must remain off-list or on discard list */ > + if (cluster_is_discard(ci)) > + return; > + > + if (!ci->count) { > + free_cluster(si, ci); relocate_cluster() is only called in alloc_swap_scan_cluster(), there seems to be no chance to have 'ci->count == 0' case when allocating. Do I miss anything here? > + } else if (ci->count != SWAPFILE_CLUSTER) { > + if (ci->flags != CLUSTER_FLAG_FRAG) > + cluster_move(si, ci, &si->frag_clusters[ci->order], > + CLUSTER_FLAG_FRAG); > + } else { > + if (ci->flags != CLUSTER_FLAG_FULL) > + cluster_move(si, ci, &si->full_clusters, > + CLUSTER_FLAG_FULL); > + } > +} > + > /* > * The cluster corresponding to page_nr will be used. The cluster will not be > * added to free cluster list and its usage counter will be increased by 1.