From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41C72B676 for ; Mon, 6 Jan 2025 10:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736158390; cv=none; b=MwD2bhU/Nz/DVKCkQ/yGe+RgD/s9Xfn5Ki0uS/ofFRDCZTKWhXHlDs+XrroZozcfG8rF05RkD0qzek4bz4Lb6CMaaCS+5VIUkiczwtSofGt5SllBEO7aG/UZacu7DZziceCyhP2P/sOs6kG2U33WfLo8cHWLw0mOpExZmRcSR+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736158390; c=relaxed/simple; bh=uvnbgDh4FGT1aW1VSI5Ln1WxX/SBu3g8QniVtD4Mu1c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jkQoRR37or2a07K5+WaJRWqMLcPaLybg6LwUTLsLjok/te+8aA3MOPjqLV9+bdtQ8djjNrpUvjYjjyR+aC8EWVDXf9fptRPX1rLTXuVzWetU16sHswvkqxHm0Hdb/BJnfXtxVxJtX+Y9wQyuSwAtvuKXOc4DxdWKqWUWc5xtKFk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=C4MMqRjX; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="C4MMqRjX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736158387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=si2kzVSfOoKVgvHpvzcI3GC2XUMv/rHIDef9HAVuf9I=; b=C4MMqRjXc54UFurZdRSQ86bfw/VLiHpSy9Dhta+hBxtVcPOoaOJmH63Rv1hq5waueuT5zv Yzk6Mel2t+lynAymtymLdQ811BkgLNJJow8JIRvGBogEgmhS/qPmdOE50OxW6k3Sp/0K9Q Bdq4/NkHwYkKhhAogsazKVFHpg/5u8M= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-106-rlfKwxxoOn6kdZacP0jRjQ-1; Mon, 06 Jan 2025 05:13:04 -0500 X-MC-Unique: rlfKwxxoOn6kdZacP0jRjQ-1 X-Mimecast-MFC-AGG-ID: rlfKwxxoOn6kdZacP0jRjQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CCB2519560A5; Mon, 6 Jan 2025 10:13:00 +0000 (UTC) Received: from localhost (unknown [10.72.112.99]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C88FB1956088; Mon, 6 Jan 2025 10:12:58 +0000 (UTC) Date: Mon, 6 Jan 2025 18:12:54 +0800 From: Baoquan He To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , Chris Li , Barry Song , Ryan Roberts , Hugh Dickins , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , Kalesh Singh , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 09/13] mm, swap: reduce contention on device lock Message-ID: References: <20241230174621.61185-1-ryncsn@gmail.com> <20241230174621.61185-10-ryncsn@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241230174621.61185-10-ryncsn@gmail.com> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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.