From mboxrd@z Thu Jan 1 00:00:00 1970 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 BCE5222318 for ; Wed, 31 Jan 2024 06:35: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=1706682919; cv=none; b=uC3gEpU/cwDcsBO6NtcNdpQZH8FOTKLEngGfKtbkbNRl/CsYW8hY7B7+v0Ho6mzZLPQv349lIiusxg20vlvVKP62eWh5unhNbnatpZ+2ul7O2iBbhiAL3juYhR7iCzJ8IgutMvZvYbi3Dn9rhGs6CmYR/Zgujj+uhIXCf/eVlp8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706682919; c=relaxed/simple; bh=+xZagpXN7sqLiajhvASWMQCFlnFmff9Vtcysb8uJ7v4=; h=Date:To:From:Subject:Message-Id; b=UDgwZEfhMM/NHmtOyFqx25Ly5EX1ZUYGlTse6hoOSAWDeJJIoBlE/yCwd5xseNdb9jUWq/DCbxvqkPKMv9tQ6LN/M/4gj2pHjAu/SxLaFSIyeNn0xbxTLAcruNY/4xMrlhExp+zWCbR/twoQxG64rE5a/x8YXRuiMCRYlkmVfWE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=V7NuF31V; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="V7NuF31V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7773FC433C7; Wed, 31 Jan 2024 06:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1706682919; bh=+xZagpXN7sqLiajhvASWMQCFlnFmff9Vtcysb8uJ7v4=; h=Date:To:From:Subject:From; b=V7NuF31VM0xRoYYfIdPil7CeH5JkFvs0Rk42PxfpRbFSsX58mPS1ipfIXvmM70ZMs NjviIShhsFCiKxcZKPXtTchLoIIKKsQ1L9/DuP11N3lmcZM6wH5P6Y46HOPhpxU7p2 qjaAD9t8zJ0x17T3K9XGoqy9+UxXDyY+Mz2iqJvc= Date: Tue, 30 Jan 2024 22:35:05 -0800 To: mm-commits@vger.kernel.org,ying.huang@intel.com,sthanneeru.opensrc@micron.com,ravis.opensrc@micron.com,rakie.kim@sk.com,mhocko@suse.com,mhocko@kernel.org,Jonathan.Cameron@huawei.com,hyeongtak.ji@sk.com,honggyu.kim@sk.com,Hasan.Maruf@amd.com,hannes@cmpxchg.org,gregory.price@memverge.com,fvdl@google.com,dan.j.williams@intel.com,corbet@lwn.net,ak@linux.intel.com,gourry.memverge@gmail.com,akpm@linux-foundation.org From: Andrew Morton Subject: [to-be-updated] mm-mempolicy-refactor-a-read-once-mechanism-into-a-function-for-re-use.patch removed from -mm tree Message-Id: <20240131063517.7773FC433C7@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The quilt patch titled Subject: mm/mempolicy: refactor a read-once mechanism into a function for re-use has been removed from the -mm tree. Its filename was mm-mempolicy-refactor-a-read-once-mechanism-into-a-function-for-re-use.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ From: Gregory Price Subject: mm/mempolicy: refactor a read-once mechanism into a function for re-use Date: Thu, 25 Jan 2024 13:43:43 -0500 move the use of barrier() to force policy->nodemask onto the stack into a function `read_once_policy_nodemask` so that it may be re-used. Link: https://lkml.kernel.org/r/20240125184345.47074-3-gregory.price@memverge.com Signed-off-by: Gregory Price Suggested-by: Huang Ying Cc: Andi Kleen Cc: Dan Williams Cc: Frank van der Linden Cc: Hasan Al Maruf Cc: Honggyu Kim Cc: Hyeongtak Ji Cc: Johannes Weiner Cc: Jonathan Cameron Cc: Jonathan Corbet Cc: Michal Hocko Cc: Michal Hocko Cc: Rakie Kim Cc: Ravi Jonnalagadda Cc: Srinivasulu Thanneeru Signed-off-by: Andrew Morton --- mm/mempolicy.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) --- a/mm/mempolicy.c~mm-mempolicy-refactor-a-read-once-mechanism-into-a-function-for-re-use +++ a/mm/mempolicy.c @@ -1890,6 +1890,20 @@ unsigned int mempolicy_slab_node(void) } } +static unsigned int read_once_policy_nodemask(struct mempolicy *pol, + nodemask_t *mask) +{ + /* + * barrier stabilizes the nodemask locally so that it can be iterated + * over safely without concern for changes. Allocators validate node + * selection does not violate mems_allowed, so this is safe. + */ + barrier(); + memcpy(mask, &pol->nodes, sizeof(nodemask_t)); + barrier(); + return nodes_weight(*mask); +} + /* * Do static interleaving for interleave index @ilx. Returns the ilx'th * node in pol->nodes (starting from ilx=0), wrapping around if ilx @@ -1897,20 +1911,12 @@ unsigned int mempolicy_slab_node(void) */ static unsigned int interleave_nid(struct mempolicy *pol, pgoff_t ilx) { - nodemask_t nodemask = pol->nodes; + nodemask_t nodemask; unsigned int target, nnodes; int i; int nid; - /* - * The barrier will stabilize the nodemask in a register or on - * the stack so that it will stop changing under the code. - * - * Between first_node() and next_node(), pol->nodes could be changed - * by other threads. So we put pol->nodes in a local stack. - */ - barrier(); - nnodes = nodes_weight(nodemask); + nnodes = read_once_policy_nodemask(pol, &nodemask); if (!nnodes) return numa_node_id(); target = ilx % nnodes; _ Patches currently in -mm which might be from gourry.memverge@gmail.com are mm-mempolicy-introduce-mpol_weighted_interleave-for-weighted-interleaving.patch mm-mempolicy-change-cur_il_weight-to-atomic-and-carry-the-node-with-it.patch