Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1578784lqg; Sun, 3 Mar 2024 17:52:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUrOAHCz1ilpHUDleQ31rmV2hDFaTJQzztZq1YPQadD4Swb1SL3CahK/B6RNpP0tOL4wxiiVK4z4uETqcqoPHDS4lomquWckqrOS7d+ew== X-Google-Smtp-Source: AGHT+IFgPla8QgO9nI3h5LRaa4K80Uf4k4hJTkIOxYp7mnVGPMo2MFVcC2FeGPEhwI4Zt0wCc6yg X-Received: by 2002:a17:90b:b01:b0:29a:6395:a67a with SMTP id bf1-20020a17090b0b0100b0029a6395a67amr11010761pjb.4.1709517129359; Sun, 03 Mar 2024 17:52:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709517129; cv=pass; d=google.com; s=arc-20160816; b=N4P6GRUZx6x8AcJvXzlSEd3yg5BEw/Cqk5Zroj5oI9go9bNiU75e/5Dy9GG6W73kH7 uaRu6f7TxJdbTx50B39JH+PRnxPGEbnFnRT0xnjFgXVYoL2XkmM3ghyr/Rux96/omRsa jfCGml+xXaFuQk3jUg+GoNGGyWQ3FCr7RJvjOBU3lBsWc2BwHMxBmYC2Et96yrvPD/SI 6WvZEbdvRWQhqAshta5nA5imgjkydqP+51mCOmetfTdhHXBdglh/thyIkOw7LZmDrItY Se8Iz6X4XLZX1lzMF/8BW7HkqsJrCWM48McIq6epYb2Buw+crM26DxgGvVwMbj2RgWEw H+Sg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=8m20wwbG6bH+TwRIvy7ouVkDD5j9fCnJ/ov+MfZEwh4=; fh=SCU9rrshkMrPGsHSvW7wHvXPKzV3CUYUsngoZtOHW+g=; b=w2mOANtLXCDe1tmRIr8rzOnDgAw02hc5T0/B3XBEPZZW19/E/8JwTUVJ30EiqwDk2W sX7KCkBvGVOX3aourNQDcJ97ATtDHIcJIo2GNJQlZmiDYklQIQRn0NxJYThzVovJJrtM 8SrvBqwonSIZBJbrwVOtt8C+iidMGAe+K2Wc02qK5CchFTcIpK0wCyM1wOE8x8/pFMx9 VBxx3RSCcZuLuZNkCNOWpfJFQJ7WXFsLxHjriSwIFJBEOYB0bUSc7HSuPqAtJLhxm6nW k+Kvs0LOlvVFrVbB2aXFVdC0bWfgNtthImayQXN+ebiy+mc+18YU+LHBqlz+7O9n3akU 7F+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nB6jyWDz; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-89966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m8-20020a635808000000b005cdfaea88adsi7345964pgb.774.2024.03.03.17.52.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 17:52:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nB6jyWDz; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-89966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D7056B20B2B for ; Mon, 4 Mar 2024 01:52:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 825E8138A; Mon, 4 Mar 2024 01:51:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nB6jyWDz" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 E24561362 for ; Mon, 4 Mar 2024 01:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709517116; cv=none; b=U5t3BKczjCOJuRHcqwCKhg8c0Bezky1Hxp2nWSQX1qTpxcIkE2i2SiFUQffWyPtOm3zU7OIQaDZs7zOvZs+kNT8Un45xq9a5RwSvCsK+SXoWqykCeI2ozi9ClKwdOgASBFXn6H2GsiNRpnXFeS3mfNatdVebR8q43/U2lIdjdtQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709517116; c=relaxed/simple; bh=BCLPYf9pYMiAg1zSZ7/AMXpacdKq7f33SgpfQANAkY0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=RxQTbxLWZPnqm3f4FNUGj5i1y57i1SjF462B0qKrXCitUf+s335AtnmvwvuMv+NiEmavkTenXEZFNOtYsNP9V6vFwLRI/9hGbWBSL8B2onMUNucYuxF9aJ+9fnWG/QX3Kjn1D6HI7Ca9+k2FtTk2cTxNF8jCuHhMit55c2V69+0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nB6jyWDz; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709517115; x=1741053115; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=BCLPYf9pYMiAg1zSZ7/AMXpacdKq7f33SgpfQANAkY0=; b=nB6jyWDz6lc287DmByu4nCohA0cUAEM7znGrB2Wn0h9/p1eonMAfmuK4 F9FQDGBhffiR5Aa66cpn77n/Osf0QY7CD1mV+9YhssD2mKRs1b867VGcy xeAfjwWs5UtrP9zc87vt2LUko3Nm59Cfhcv8Kx+n6fERvoDEbb3gCFQgW I3LvZX34cBIa8YnUQwQQ4nD5oK12bJIRRuKu5/nZaW/3pVHKhzhcuEUwI vtnekKsqw/HR1tattI9ch/giKZwBS3xY6EpWTBplcTgSM5HPUPJWt/T+w JuEXGsUMnA+2ee4CeZZJUJclP8coxLQW2ZEhfhxg1b8dV7UeR+2fegxFX Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11002"; a="4117144" X-IronPort-AV: E=Sophos;i="6.06,203,1705392000"; d="scan'208";a="4117144" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2024 17:51:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,203,1705392000"; d="scan'208";a="8773042" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2024 17:51:49 -0800 From: "Huang, Ying" To: Aneesh Kumar K.V Cc: Michal Hocko , Andrew Morton , Donet Tom , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , Mel Gorman , Ben Widawsky , Feng Tang , 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 Subject: Re: [PATCH 1/3] mm/mempolicy: Use the already fetched local variable In-Reply-To: <875xy3ltys.fsf@kernel.org> (Aneesh Kumar K. V.'s message of "Sun, 03 Mar 2024 11:47:47 +0530") 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> <21f343fa-84a7-4539-91e2-6fc963dbfb62@kernel.org> <87frxnps8w.fsf@yhuang6-desk2.ccr.corp.intel.com> <7097ff95-6077-4744-a770-b90d224c0c9b@kernel.org> <8734tnppls.fsf@yhuang6-desk2.ccr.corp.intel.com> <875xy3ltys.fsf@kernel.org> Date: Mon, 04 Mar 2024 09:49:54 +0800 Message-ID: <87sf16bwal.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) 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=ascii Aneesh Kumar K.V writes: > Michal Hocko writes: > >> On Tue 20-02-24 15:22:07, Huang, Ying wrote: >> [...] >>> This isn't an issue now, because mpol_misplaced() are always called with >>> PTL held. And, we can still keep thiscpu local variable. >> >> yes, this is the case but it would be better if we made that assumption >> official by lockdep_assert_held >> > > How about this folded into this patch? > > 2 files changed, 12 insertions(+), 4 deletions(-) > mm/memory.c | 6 ++++-- > mm/mempolicy.c | 10 ++++++++-- > > modified mm/memory.c > @@ -4879,9 +4879,11 @@ static vm_fault_t do_fault(struct vm_fault *vmf) > return ret; > } > > -int numa_migrate_prep(struct folio *folio, struct vm_area_struct *vma, > +int numa_migrate_prep(struct folio *folio, struct vm_fault *vmf, > unsigned long addr, int page_nid, int *flags) > { > + struct vm_area_struct *vma = vmf->vma; > + > folio_get(folio); > > /* Record the current PID acceesing VMA */ > @@ -4893,7 +4895,7 @@ int numa_migrate_prep(struct folio *folio, struct vm_area_struct *vma, > *flags |= TNF_FAULT_LOCAL; > } > > - return mpol_misplaced(folio, vma, addr); > + return mpol_misplaced(folio, vmf, addr); > } > > static vm_fault_t do_numa_page(struct vm_fault *vmf) > modified mm/mempolicy.c > @@ -2495,18 +2495,24 @@ static inline bool mpol_preferred_should_numa_migrate(int exec_node, int folio_n > * Return: NUMA_NO_NODE if the page is in a node that is valid for this > * policy, or a suitable node ID to allocate a replacement folio from. > */ > -int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma, > +int mpol_misplaced(struct folio *folio, struct vm_fault *vmf, > unsigned long addr) > { > struct mempolicy *pol; > pgoff_t ilx; > struct zoneref *z; > int curnid = folio_nid(folio); > + struct vm_area_struct *vma = vmf->vma; > int thiscpu = raw_smp_processor_id(); > - int thisnid = cpu_to_node(thiscpu); > + int thisnid = numa_node_id(); > int polnid = NUMA_NO_NODE; > int ret = NUMA_NO_NODE; > > + /* > + * Make sure ptl is held so that we don't preempt and we > + * have a stable smp processor id > + */ > + lockdep_assert_held(vmf->ptl); > pol = get_vma_policy(vma, addr, folio_order(folio), &ilx); > if (!(pol->flags & MPOL_F_MOF)) > goto out; > > [back] > LGTM, Thanks! -- Best Regards, Huang, Ying