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 9810FC71136 for ; Mon, 16 Jun 2025 22:16:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0541A6B0089; Mon, 16 Jun 2025 18:16:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02ABE6B008A; Mon, 16 Jun 2025 18:16:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA9C46B0093; Mon, 16 Jun 2025 18:16:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DBC686B0089 for ; Mon, 16 Jun 2025 18:16:31 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AD6C5BE8FD for ; Mon, 16 Jun 2025 22:16:31 +0000 (UTC) X-FDA: 83562673782.28.3F244BD Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf07.hostedemail.com (Postfix) with ESMTP id BC70840006 for ; Mon, 16 Jun 2025 22:16:29 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=UBIpgml+; spf=pass (imf07.hostedemail.com: domain of bijan311@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=bijan311@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750112189; 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=L4x/p8NEu399tKFp+L82OEsMeF0ul8epvOoGorBxox8=; b=Cwj+dvTweIorrYsgcD2RgPwYby+B7IAzflges0cAzAINrUsj84lLKzf7Jxwc92iywlU2GV 3NWlTl2Jub2jugV7+8MdfXyMzYWXUbyjrIdI4shuOOw9d7rS5pGbHoLDbJRGDEr1YRJMRQ Y+scO+AHSOjJig+E/98eC586GGKOS24= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=UBIpgml+; spf=pass (imf07.hostedemail.com: domain of bijan311@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=bijan311@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750112189; a=rsa-sha256; cv=none; b=hX53HHKAGsfzEQXwER5cgvUpFwogfGXhTXitp6dzyET2oFcxJ8cdKiFctibpATxU0/+8/E F2TxQLV834TWrRuwUjK9dWJBxmnTXkHnlEzIQe4UJlqiVR2p8DxBV816jniHaCdtdrrv6n kPiWZ+RfvJwFw9YbnqUrMC9Ow8DgrPs= Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-addda47ebeaso1012230866b.1 for ; Mon, 16 Jun 2025 15:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750112188; x=1750716988; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=L4x/p8NEu399tKFp+L82OEsMeF0ul8epvOoGorBxox8=; b=UBIpgml+B7xQh2Wskaj1Clz2wjuAxSUGM8JHY3vVUyRg0gQ/Vlm/z7wT2HAv60aW3l 2OllG7I65foU0jHZZO8o4aoY39Rt8vFeuaD6qtCtAZGKbD3X2vvFpjFCLfGf4RydLTve JP+8GlTMZvwz4NhFfmmtu8WqHKC0HEoRm7yggx1OoWbB9ozFtUkmnruhR6oQPU/D86xk IbAMNjY75GedQJG7hq1bxDkmA0Rg0E9dOGWLDkGJUYVvG3EtNXaz6FdRQkQ4jeF5kuNF 4ytjZJgGwYJAXYw6ZDlUy8qen59b9cFQne8Sqd66s0IX72+xXAuQVlU/bdK68XJFcrqA njWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750112188; x=1750716988; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L4x/p8NEu399tKFp+L82OEsMeF0ul8epvOoGorBxox8=; b=JM8fNPLQO/Og62S2VPdzJTIXO9QLbMnOU11b4a1RFFgo90X3i37dxbtehoeXv241g0 nExYk6Ot5RFQBTPka+YEHTV/AYm4XvozHyiAFk1W726W5lVwCWtj9R8pGp5QrlCRUILe 1OPd9BtK4a4SMtXWJ2MOXZ+VYNtwj0aifdmOzMUTa+CHfv544abLSM99juPh/dcvA8Ct j0O0djDp1nr3ugVfLdl2RRsZ8suwKqGDoZHhCWpz84BZYkRdLreqWiVBKb2Yt9W2ST97 e/qh91T9+GPK0F9DmgImvHzfdQjtkbGMhdMoDSJXf7sHgN6wg7S2GZyouEN8DLDVRDeB 12hw== X-Forwarded-Encrypted: i=1; AJvYcCW2WuIlxJUpsY1ua9zZ9Ewet3GhR/nSBly9RlzBvKWGAAJtEnycse5mwkckoEHFc7RNxp/gGGrJ5w==@kvack.org X-Gm-Message-State: AOJu0YxBlBnWWps/ILRLAcJOmAywsVsWPpf5J5o3MwFLHJ1GJBUWVM1a MR89sKHTCAoEkkUQU14EGXF67D50LnXgBzl4Q5SvdBa4FbhARbdA3EFEb5J3NY41bdsRG1dmwkP stG14ze4O9NzOeWfmHxwiOOjTykajfvE= X-Gm-Gg: ASbGncsIAa0QBrZ1EYNjcFAs3gdlbq7N1h6oFYaEA9AhBI0zrgtziemIhI+67y6hIDY Jgn0un6xFqlyiiyYSYOgpRvyzroY3qYCheJBJzwBg7d2uv7uRujUe1P0YgXjCPrApmJjixYHEmg 7WUVrScC3kLyQwzuh6TVkfgYi8r4hAUMZuJnuENaSh3HGPOeHj9wgTcc1n0QI2SuwDGOZPsqjtw HrTvA== X-Google-Smtp-Source: AGHT+IHWhKGzFlw/YafR+gXhZspwtYe6gkGuL7wwEgT/ACXbIUqtoGIZWUoj26D8y8Znb1z69yrl5bOG+d7vxjTvsJ4= X-Received: by 2002:a17:907:608b:b0:ade:3bec:ea29 with SMTP id a640c23a62f3a-adfad397276mr976447066b.25.1750112187830; Mon, 16 Jun 2025 15:16:27 -0700 (PDT) MIME-Version: 1.0 References: <20250612181330.31236-1-bijan311@gmail.com> <20250612181330.31236-2-bijan311@gmail.com> <5a50eeba-b26d-4913-8016-45278608a1ee@redhat.com> In-Reply-To: From: Bijan Tabatabai Date: Mon, 16 Jun 2025 17:16:16 -0500 X-Gm-Features: AX0GCFtwj_QtqJXZ5jL7Wr8rfNEzrgEzB0jYXSU_0HLJ7kNaT0LSOgSWCHGca98 Message-ID: Subject: Re: [RFC PATCH 1/4] mm/mempolicy: Expose policy_nodemask() in include/linux/mempolicy.h To: Gregory Price Cc: David Hildenbrand , linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, sj@kernel.org, akpm@linux-foundation.org, corbet@lwn.net, ziy@nvidia.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, ying.huang@linux.alibaba.com, apopple@nvidia.com, bijantabatab@micron.com, venkataravis@micron.com, emirakhur@micron.com, ajayjoshi@micron.com, vtavarespetr@micron.com, damon@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BC70840006 X-Stat-Signature: bk7nihkj44my3e3gxhuynrgscccuj44b X-Rspam-User: X-HE-T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AUwyCZ6NuYsWRt77Pfjs7D0mk3vx425HvOJzwhJBMuZXUhGIMEGn4deG5XkIRqrzPW1XE5ksmPzwdAe+jvJ6Yd56+4QksR07X1xB9ajVF2FvCrKrUIbYwLURKW0fJZCRCdUv6LSiVYiv9lYBkozInBSOzG418Maha2XDWsl3pBv5MlLiFjhWRwqY0dBsxYiTKwrmbt7dpiuxcvyrtRUnAKDc7PoM3fVuRSd+Rdq3vArbyDflMgbuVrP3t1mERxGyk5oF7PSPkospXFx/Ig6JxMduyGOWLzosT3x5//N+fCedK4WjWG9PpZKeDygJWh5y3Zde1LTTsjZAQJyeb7KNiIU4zZUUe+K5jnxI8Iw9WL3cx8vEZMZm+TreXQ0GjDLCgYMxuH73smfz544m9SwCwMZVWJhNETliqu0O9GONEwnhw4C0fDtNE2K68IkbQ== 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: Hi Gregory, On Mon, Jun 16, 2025 at 12:43=E2=80=AFPM Gregory Price = wrote: > > On Mon, Jun 16, 2025 at 09:16:55AM -0500, Bijan Tabatabai wrote: > > > > > > Which, you also have during the rmap walk. > > > > There is another subtle dependency in get_vma_policy. > > It first checks if a VMA policy exists, and if it doesn't, it uses the > > task policy of the current task, which doesn't make sense when called > > by a kdamond thread. > > > > However, I don't think this will change what seems to be our consensus > > of adding a new helper function. > > > > Hate to interject here, but this gets worse the further you dig in. The > mempolicy interface as a whole has many, many, many hidden references to > current->mempolicy and current->mems_allowed. External interface > references to a task or vma mempolicy is a problem i explored somewhat > extensively when I prototyped `set_mempolicy2()`. It did not go well. > > Generally, mempolicy is not well structured to allow external actors on > a task's mempolicy. Accessing a task's mempolicy requires operating in > a task's context or at least taking a reference on that task's mempolicy > (which requires taking the task_struct lock). Good point, I didn't take the lock in the second patch. Also, this made me realize I need to make sure there isn't a race condition where a task exits after getting a pointer to its task_struct from mm->owner. > I will just say that mempolicy is *extremely* current-task centric - and > very much allocation-time centric (i.e. the internal workings don't > really want to consider migration all that much). You'll probably find > that this project requires rethinking mempolicy's external interfaces in > general (which is sorely needed anyway). > > I think this path to modifying mempolicy to support DAMON is a bit > ambitious for where mempolicy is at the moment. You may be better off > duplicating the interleave-weight logic and making some helper functions > to get the weight data, and then coming back around to generalize it > later. This may be true, but I think I will be able to avoid a lot of this nastiness with what I need. I am going to try with the mempolicy approach for the next revision, but if I get too much resistance, I will probably switch to this approach. Thanks, Bijan