Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp69647lqh; Fri, 3 May 2024 13:44:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW673zTgVpZmpkyIyXoLa446NkA2gGlAZ6jE2wZOFqkvqJFdWuhw3pNQJinpE3UyIF+LpASy0+EUMnGSnslQS5259YZFAkGEme9GyoPXw== X-Google-Smtp-Source: AGHT+IG5m3M2tph0KSktFByxWP7vVeEa6Nmvs8w+hwo6bk34QXzj7Fa9tnKQkq8MFZBWf9YUMrQZ X-Received: by 2002:a05:6a00:2e26:b0:6ed:e1c:102e with SMTP id fc38-20020a056a002e2600b006ed0e1c102emr4541668pfb.24.1714769057757; Fri, 03 May 2024 13:44:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714769057; cv=pass; d=google.com; s=arc-20160816; b=EifvE2dCfZmIODjD2egFLXHjO5CH7UtU7XduAWZZIM8EA5bJBBFk+WPnGRZYRRSmLG kq3J8+kRNEksYropKnBxGOiZsuwz/ntLs6q2P6hLtzJ+KuudfRFFWO1RvuAS+qqnib3u z4g8y0foUO/asSKOEpeeCh1xzjXcglaOEVlqwllX2oMY8tR+Yv3DOwyXLjC5r3MWF7j3 UvGSkJUjn8Q3yhF+HCvKkPDCz2d3ZE9wikaBrVCNOUnMZUUnOnrWzfvuiyWeLymoHmKH /FBjYT6m9uikwkpULwddle1DDyrfHeTYWY9RDOasXsNqJg+kxQHQksxjfLaylVwjGVCT /k2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=oCRyRt1bfDa4/NS27EaMJXqhiwT7fzju5HCCNKSsYY0=; fh=tNa/zc29r8jeiKjf9H8PuPYTa4cxC5yxyUu3miLgz+k=; b=G/Yx8EkaRAQySoVFCkgT+ek2xOyND+UTakoFJi2Vf6vz1gSteTk8DBYA4NQH0NIYML 0rscJciYP9dhlh2P1bvRk+Wi9XDuBmHstWcVNqJ3/vzMPGWHhS7NC6hSxPCtQdKhAEhW kX4O+jycVra3onEvA5ZjQOJeM2BSei8r1nQFgW/kZzBwqAZXbGtQX+jvysphv05ow+Zg /sy5oWnr2ikUFjxjAbrBauIXGxKjkhfabD/zMPwy1/LhbpCmdDvyUPbqb0P14U2vnAHt mHVKYACche9JCLZDU1BaPSUXx0NsVpYSkDGdeiCCS2vNEt9kKGOtON+PP6Z8laYIkNHB xLeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EsqdJ6Oc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168196-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cz17-20020aa79311000000b006eab069cdc0si3614584pfb.160.2024.05.03.13.44.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 13:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168196-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EsqdJ6Oc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168196-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C6A162875D1 for ; Fri, 3 May 2024 20:37:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6ACD9250F8; Fri, 3 May 2024 20:37:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EsqdJ6Oc" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 961151C68C for ; Fri, 3 May 2024 20:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714768639; cv=none; b=BqRs+xOot0qqzyWhwmNaSqDxJuS5EgWkQ5mp8Ih5GJytXEp1I9tY0vI+6aoHAHXSH/cHhkltmZmoCkIxUWwp8x/QJ2Odto9DN9cfVTXhUxSCi+0vGKAhYWeG2nkIjTLkbPWaM2egr0b9Lvi/b1yC/Pr7Y1eoSP1tGEKUsZrpizU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714768639; c=relaxed/simple; bh=Ro+9bsKaVb7uKrUgAz6odmTDr5TLuTDADOERyWJUfzo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=bdvdJi0SVtwujnTcRJkKqvTYRXOEzPPNOPfwRVuG7atHRGXv3GrvHPJShUA1NTWRJOCrUz3o/AOc8yTa/AW6h+Zf65NeVblUWTFqs43ofuS6Hb/UZ/Bzd7Ux9S2ztZVjTG3lx3UJSI2nD+6ux7K8tydJ380yvk/0LxHSPtfFAJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EsqdJ6Oc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29849C4AF1D for ; Fri, 3 May 2024 20:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714768639; bh=Ro+9bsKaVb7uKrUgAz6odmTDr5TLuTDADOERyWJUfzo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=EsqdJ6OcJWETWUhpCwpMA7kVhcwZbo4QGKsPZtOs9q7uO3/eGBBBCWZKREVzl4RIK hdAiCBv1k9GwUDF4nK0yl6Qwwr0GnMu7WtEcF/WYH00xkIr5jlvxoDXKdqlfOSCN9V XUaxC4s/2EMuszcHyJxbBP5SWt2UHBHOf41LJqsYJzcWS4impzbgs9NahTZuFGDI08 90zPJ5xsZ4PxCL807Y4t6UPj//c+N3fpOcxH8ImzjStW3kzck2w6W04G39nB+sQyjW qHWKENAVkMtKy42gzCGJs+1fSuJsLhRRU7qjmW64MDaB8Yzyz6LkrNyPqJ7DAIMaIJ ggBwULvOxCwTw== Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2db6f5977e1so987431fa.2 for ; Fri, 03 May 2024 13:37:19 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCX+kwxqv5szS0SXyDll0Or9caOhO3VaTANkAZF4EYVVEXIiHZ4I9ZhD93ayx9ga4c5nD2hbjNvNi0e7vJBMYq4ya6wzhFhoxyWoBtzK X-Gm-Message-State: AOJu0Yy1q2WllTQX5qUlZnMNaRclL97RQuiyGhKTB2S/3KLfLXHkLn49 WROHYc2KXRFIEfb+pffuurmOKijTlw9fBvKvkSuTv6CAAihEIDXeO0jat/KkXY4kfa26T9+GT7B j/kFqOS+eYENZ+nm8cYHlEwKmUQ== X-Received: by 2002:a2e:9d19:0:b0:2e1:eb27:3513 with SMTP id t25-20020a2e9d19000000b002e1eb273513mr2443272lji.52.1714768637832; Fri, 03 May 2024 13:37:17 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240503005023.174597-1-21cnbao@gmail.com> <20240503005023.174597-3-21cnbao@gmail.com> In-Reply-To: From: Chris Li Date: Fri, 3 May 2024 13:37:06 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 2/6] mm: remove swap_free() and always use swap_free_nr() To: Ryan Roberts Cc: Barry Song <21cnbao@gmail.com>, akpm@linux-foundation.org, linux-mm@kvack.org, baolin.wang@linux.alibaba.com, david@redhat.com, hanchuanhua@oppo.com, hannes@cmpxchg.org, hughd@google.com, kasong@tencent.com, linux-kernel@vger.kernel.org, surenb@google.com, v-songbaohua@oppo.com, willy@infradead.org, xiang@kernel.org, ying.huang@intel.com, yosryahmed@google.com, yuzhao@google.com, ziy@nvidia.com, "Rafael J. Wysocki" , Pavel Machek , Len Brown Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 3, 2024 at 2:31=E2=80=AFAM Ryan Roberts = wrote: > > On 03/05/2024 01:50, Barry Song wrote: > > From: Barry Song > > > > To streamline maintenance efforts, we propose discontinuing the use of > > swap_free(). Instead, we can simply invoke swap_free_nr() with nr set > > to 1. This adjustment offers the advantage of enabling batch processing > > within kernel/power/swap.c. Furthermore, swap_free_nr() is designed wit= h > > a bitmap consisting of only one long, resulting in overhead that can be > > ignored for cases where nr equals 1. > > > > Suggested-by: "Huang, Ying" > > Signed-off-by: Barry Song > > Cc: "Rafael J. Wysocki" > > Cc: Pavel Machek > > Cc: Len Brown > > Cc: Hugh Dickins > > --- > > include/linux/swap.h | 5 ----- > > kernel/power/swap.c | 7 +++---- > > mm/memory.c | 2 +- > > mm/rmap.c | 4 ++-- > > mm/shmem.c | 4 ++-- > > mm/swapfile.c | 19 +++++-------------- > > 6 files changed, 13 insertions(+), 28 deletions(-) > > > > diff --git a/include/linux/swap.h b/include/linux/swap.h > > index d1d35e92d7e9..f03cb446124e 100644 > > --- a/include/linux/swap.h > > +++ b/include/linux/swap.h > > @@ -482,7 +482,6 @@ extern int add_swap_count_continuation(swp_entry_t,= gfp_t); > > extern void swap_shmem_alloc(swp_entry_t); > > extern int swap_duplicate(swp_entry_t); > > extern int swapcache_prepare(swp_entry_t); > > -extern void swap_free(swp_entry_t); > > I wonder if it would be cleaner to: > > #define swap_free(entry) swap_free_nr((entry), 1) > > To save all the churn for the callsites that just want to pass a single e= ntry? > Either way works. It will produce the same machine code. I have a slight inclination to just drop swap_free(entry) API so that it discourages the caller to do a for loop over swap_free(). Acked-by: Chris Li Chris