From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BD83C48BC4 for ; Tue, 20 Feb 2024 04:10:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 387FF6B0082; Mon, 19 Feb 2024 23:10:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3385B6B0083; Mon, 19 Feb 2024 23:10:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 227506B0085; Mon, 19 Feb 2024 23:10:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 11C836B0082 for ; Mon, 19 Feb 2024 23:10:17 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E129C1205A6 for ; Tue, 20 Feb 2024 04:10:16 +0000 (UTC) X-FDA: 81810854832.13.DA2C59E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf04.hostedemail.com (Postfix) with ESMTP id 8632B40015 for ; Tue, 20 Feb 2024 04:10:14 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=X0x0FCUo; spf=pass (imf04.hostedemail.com: domain of aneesh.kumar@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=aneesh.kumar@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708402215; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ij8qCis0Q2y7OYK10w842eOor/v2ccENWTQ8YXRNKN4=; b=H3Q0CUVnbIHDhiWVTEtTJ5DzjNYSSnXQMWG9s/8EjcsQWiFfgBXZuTlY97QPHwhgC05JqH VRobkfhITrPMp6NsxH8EDC/li0sWsxPFqKYLLuzsXXRz2q/Z8ZQWhLQBuhTOOvaevhiN0E QiWwKGaGqXVd0ZrPGrwIbQMf0VmPVBM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708402215; a=rsa-sha256; cv=none; b=7sqzKMRDROTasB6VVbdgBxRtC5o0LWINlueAuD9pYygK3MknCDD8u8QFo7wHmSXVVt9ubQ t7Lwc8xMQdY+Ox8WGZ690XdBdB6KxxAnftKEKo4BZC3XAvWis6aAHOIUJzhoTOK7I+Fkkt TRLyCAe1dDp8tiXuB3DDIqPQ7Wcr8NE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=X0x0FCUo; spf=pass (imf04.hostedemail.com: domain of aneesh.kumar@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=aneesh.kumar@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2D7C3CE149E; Tue, 20 Feb 2024 04:10:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B26A7C43390; Tue, 20 Feb 2024 04:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708402210; bh=KKHHRdVhhgZ9aWQzJ7mjvLx6wN0urMkPn6mNuza3z9Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=X0x0FCUossxV1bBbCmQT9HhLxk0SSYRolnLvORHtXWsYx3cFWrZPMKEJZy0kfAggv nlxbMiwTK51yLipQgJtARMTFscIcUoQTsT1A9WCdI5JOHBeTeyEwVlM0JSMeV8Pxy3 81KgVTLZxLiDFOoSmOOM6GSsuAV33KVqdkxriG+F3B75PkIueN6U80FRbp6vWvldmw 3eEouoftA8Azo/Swy22m4heA/sPdtfAAuv12SNr6UxQEl2IOnyYtF5/ooRrutj2s7k LhwZpartF/KcIJOl+pDC9bAMQKVwu67nKlgHX+PlVds9uTXuP0894BaMEjHTl7v02q 1cQnAsxA2RxpA== Message-ID: <21f343fa-84a7-4539-91e2-6fc963dbfb62@kernel.org> Date: Tue, 20 Feb 2024 09:40:00 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] mm/mempolicy: Use the already fetched local variable Content-Language: en-US To: Andrew Morton , Donet Tom Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Dave Hansen , Mel Gorman , Ben Widawsky , Feng Tang , Michal Hocko , Andrea Arcangeli , Peter Zijlstra , Ingo Molnar , Rik van Riel , Johannes Weiner , Matthew Wilcox , Mike Kravetz , Vlastimil Babka , Dan Williams , Hugh Dickins , Kefeng Wang , Suren Baghdasaryan References: <9c3f7b743477560d1c5b12b8c111a584a2cc92ee.1708097962.git.donettom@linux.ibm.com> <20240218133851.22c22b55460e866a099be5ce@linux-foundation.org> <63a0f7c4-3c3f-4097-9a24-d1e3fc7b6030@linux.ibm.com> <20240219172130.82a16c1ebecbf8ba86a8987d@linux-foundation.org> From: "Aneesh Kumar K.V" In-Reply-To: <20240219172130.82a16c1ebecbf8ba86a8987d@linux-foundation.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 8632B40015 X-Rspam-User: X-Stat-Signature: 1gnpha5n87ti3oz5j458e7hyzmg46ohw X-Rspamd-Server: rspam03 X-HE-Tag: 1708402214-622329 X-HE-Meta: U2FsdGVkX1+1yt2yrr14wcMrQjGSi+Ge0aWhnCOzMckA7BjTM6TE/qI6miLA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U/Ic9jc2wEdr4pLA8nOUqnQ0FvcYNJqayPIlp5xCqjDDjkx7V/EKKIyfVCcyGTcU6bmThvVb5V+6bM6w/PPQJPiLBfQKaflnA/5zYpcbo9zj4en3kw X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2/20/24 6:51 AM, Andrew Morton wrote: > On Mon, 19 Feb 2024 14:04:23 +0530 Donet Tom wrote: > >>>> --- a/mm/mempolicy.c >>>> +++ b/mm/mempolicy.c >>>> @@ -2526,7 +2526,7 @@ int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma, >>>> if (node_isset(curnid, pol->nodes)) >>>> goto out; >>>> z = first_zones_zonelist( >>>> - node_zonelist(numa_node_id(), GFP_HIGHUSER), >>>> + node_zonelist(thisnid, GFP_HIGHUSER), >>>> gfp_zone(GFP_HIGHUSER), >>>> &pol->nodes); >>>> polnid = zone_to_nid(z->zone); >>> int thisnid = cpu_to_node(thiscpu); >>> >>> Is there any dofference between numa_node_id() and >>> cpu_to_node(raw_smp_processor_id())? And it it explicable that we're >>> using one here and not the other? >> >> Hi Andrew >> >> Both numa_node_id() and cpu_to_node(raw_smp_processor_id()) return the current execution node id, >> Since the current execution node is already fetched at the beginning (thisnid) we can reuse it instead of getting it again. > > Sure, but mine was a broader thought: why do we have both? Is one > preferable and if so why? IIUC these are two helpers to fetch current numa node id. and either of them can be used based on need. The default implementation shows the details. (One small difference is numa_node_id() can use optimized per cpu reader because it is fetching the per cpu variable of the currently running cpu.) #ifndef numa_node_id /* Returns the number of the current Node. */ static inline int numa_node_id(void) { return raw_cpu_read(numa_node); } #endif #ifndef cpu_to_node static inline int cpu_to_node(int cpu) { return per_cpu(numa_node, cpu); } #endif In mpol_misplaced function, we need the cpu details because we are using that in other place (should_numa_migreate_memory()). So it makes it easy to use cpu_to_node(thiscpu) instead of numa_node_id(). -aneesh