From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FA8A397342 for ; Mon, 29 Jun 2026 18:47:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782758863; cv=none; b=FEFor/AkWY0kHQ5EJXq1Ol9DiLGH82+xPLJWW/OoaYA3Ij4eisacMyiB8wsn1+ZvoGOvX8lY800ojVUm2WCVkovb3Khjtg1Bc8CuJ1W6xsP7P/i/2owSsu2nIs5MuXXtQEjTJA0iosE4gQoWnb/Ia+m6h7fuhW6XKIrjYY2oeq8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782758863; c=relaxed/simple; bh=E1hE/XZSNIPpNQI9PKzJl0Y4fUd5LqwGVXlrolPS1bo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KtQB+UEZYtB5066Nnfiq5GxscR6GmmiLcWrgz1IIfnc+euRfCjsbfw0fjZB+k+x6LN0eoVLHjUYfJusCa2SOGeNxAYgHh+gcCRJ3n2MZ5cAXJv+eyDi5oSTr8xl4OM5n4xdounMOa7oouJTctbDQemaEmXbQAF7WuyQzjrvi9hM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=ORmykhGG; arc=none smtp.client-ip=209.85.160.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="ORmykhGG" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-51c0c68aa31so5977861cf.3 for ; Mon, 29 Jun 2026 11:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1782758860; x=1783363660; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7ysXCP313kAdt03KShf1kvSecozhx/22zS/+otoUNAg=; b=ORmykhGGOQKteFH0M5XWC4EnPJ9OsDCfDcumTyv0dV/lMnjuVT5M4vaxGjrUr0XOCD xpFLT7/4VYDO+gFiBoLggccfxJ6WfZloj5xq0LWwqSI3ViMBst9wsWp1pD6ve1tSzMtC w8tXCtz1BvDQL3/1ccGgmv7VTyfkDdfGye6xIllMFJ1Ym0abTx37JZgs7Ms7VExV2vRf sYcQrXEWn+2l1GxeenaeV43GHXlw1hrwkWHFBY6gQbV8WfEKiRXtBaJFw7wE0U4eI44s t8Z3U+/VV8xuleeQpopjsplePklFcMJaWz+dzpyxRo1spYcc1IKRAk0rKeu5qHmLvctU 1/lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782758860; x=1783363660; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7ysXCP313kAdt03KShf1kvSecozhx/22zS/+otoUNAg=; b=XdpX7uQFcLh9uJDeJgdz4GDHjflJmT33I8FpIPMs8495OMWbkItBumDKsT+Tuj3yM/ Sy6Br407oy2uDAMPF3qHpZUoC6o0PQRAyGJiVx110PwB5EmliyQL8tmtud2XAAMTt95w TcUq9OL/6BYX4kzKa4e0SjlxPhGlOhMVnIIFDpdRDSSYgByCu7JHjo09/7L9sKOfkSYw T8BAJOf6NZrsi+tFAtf/VTvqGkcURzfv6MsYgoK8OWaDHK1LlQ8KihwgiL2bYRC33oxd 95Qo3lMt0FMMH02c9mek6b+P4z6mge3bufOq3p0LvArx9VPkPgbZOs64WtVPQn3/22CZ DU+g== X-Forwarded-Encrypted: i=1; AFNElJ94OCBaPFneJnyl8j9wsitb1B9be64wfocuiaY1H5CLHMT0INGahLfKsjGLORb0M1e7uH/ztjVOupHFSqA=@vger.kernel.org X-Gm-Message-State: AOJu0YwZwfErM6V5ISGz10Br/w9V6rKX2uXz/yS++fqNUGE8FSho7JZK TOciNRzzLbxleFPh9yXVOpybNE3Jah2LS26zF7n2WGXUxdF5E1JUooi7QZ7hy4QC1+8= X-Gm-Gg: AfdE7cloU0Wz33S21hNvQtzdKBmkG2c+BWEt03IeGOldq8iXMyVJ0jAXw5aUmDgZG4l FqEhkC/EdkkpaoDgHcVDG4RvUq7Q9ZcxUVPO9Xs3ODQjqOUJktOUZNUAsQRmTT2MCO2gKcMeZmN 134bzpepVMYyABx8lrPm9lQgJncfO4ZlPEBwwYig5ZJEWMKPUKhq7nDhjbst4sggK/ezG1AjPEa xvx9CI62ydW4LN01DSpZd08Pe7t4IZ0uJRtzMYfdvepJyqay2KIM4aqBMbMu5FMQYI8tXGY0x38 XOjDOdFsAloLi2bTEmRbUHHjD5AILmjlW4MfmcM2UV7oU/wugLH3ZUdXwJ6LKdB+ZXQqqFiwB7q ZJCCPE43BEVmkN0rmXycOowYzSkcQIGqJtsxfhpOLlEZzr5iKJvHIs+1UPaNwgGi3brAGrNl4zU hnvqHevWd51Xs= X-Received: by 2002:a05:622a:5792:b0:51c:6b6:9d0b with SMTP id d75a77b69052e-51c1072cb39mr7475191cf.2.1782758860012; Mon, 29 Jun 2026 11:47:40 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51c10862ecbsm2517521cf.11.2026.06.29.11.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 11:47:39 -0700 (PDT) Date: Mon, 29 Jun 2026 14:47:38 -0400 From: Johannes Weiner To: "David Hildenbrand (Arm)" Cc: Andrew Morton , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Neha Gholkar Subject: Re: [PATCH] mm: mempolicy: fix automatic numa balancing for shmem Message-ID: References: <20260629163337.1264881-1-hannes@cmpxchg.org> 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: On Mon, Jun 29, 2026 at 08:33:32PM +0200, David Hildenbrand (Arm) wrote: > On 6/29/26 18:33, Johannes Weiner wrote: > > Neha reports that mapped shmem aren't considered for NUMA balancing, > > noting convergence problems and bandwidth bottlenecking for cachelib > > based workloads on tiered memory systems. > > > > Looking at the code and going through the git history, this doesn't > > actually seem intentional: > > > > Commit fc3147245d19 ("mm: numa: Limit NUMA scanning to migrate-on-fault > > VMAs") added a vma_policy_mof() gate to task_numa_work() so VMAs whose > > policy lacks MPOL_F_MOF are skipped from NUMA balancing scans. The > > motivation was a real usecase: Oracle was pinning shared segments with > > mbind(MPOL_BIND) so trapping faults was both expensive and pointless. > > > > The handling of NULL from vm_ops->get_policy, however, treated "user > > explicitly opted out" the same as "user never specified anything." For > > VMAs whose shared policy is absent - the common case for shmem - the > > scan was disabled too. > > > > This issue is old. It probably hurts less in conventional NUMA. But it's > > very noticable on tiered systems, where entire tmpfs workingsets can get > > stuck on lower-bandwidth memory. > > Sounds bad enough to warrant CC: stable? No objection from me. I was hesitant because it's old, and while these are real workloads that see it they are hardware/kernel validation runs. OTOH it's a straight-forward bug and should backport easily. > > Signed-off-by: Johannes Weiner > > --- > > mm/mempolicy.c | 21 ++++++--------------- > > 1 file changed, 6 insertions(+), 15 deletions(-) > > > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > > index 36699fabd3c2..bba65898aee1 100644 > > --- a/mm/mempolicy.c > > +++ b/mm/mempolicy.c > > @@ -2057,24 +2057,15 @@ struct mempolicy *get_vma_policy(struct vm_area_struct *vma, > > bool vma_policy_mof(struct vm_area_struct *vma) > > { > > struct mempolicy *pol; > > + pgoff_t ilx; > > + bool mof; > > > > - if (vma->vm_ops && vma->vm_ops->get_policy) { > > - bool ret = false; > > - pgoff_t ilx; /* ignored here */ > > - > > - pol = vma->vm_ops->get_policy(vma, vma->vm_start, &ilx); > > - if (pol && (pol->flags & MPOL_F_MOF)) > > - ret = true; > > - mpol_cond_put(pol); > > - > > - return ret; > > - } > > Okay, we used the fallback of vma->vm_policy before (if vma->vm_ops->get_policy > was not available), which is what __get_vma_policy() does at well. > > But if vma->vm_ops->get_policy now returns NULL, we fallback to get_task_policy(). Yep. > Makes sense to me although this is a source of confusion for me. How so? Is there anything I can improve in the changelog? > Acked-by: David Hildenbrand (Arm) Thanks David!