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 6D3C8C5AE59 for ; Thu, 5 Jun 2025 22:39:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D45C86B00D0; Thu, 5 Jun 2025 18:39:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF5026B00D1; Thu, 5 Jun 2025 18:39:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE3C16B00D5; Thu, 5 Jun 2025 18:39:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9F9586B00D0 for ; Thu, 5 Jun 2025 18:39:14 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 40F5AC18F5 for ; Thu, 5 Jun 2025 22:39:14 +0000 (UTC) X-FDA: 83522814228.24.E18171D Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf06.hostedemail.com (Postfix) with ESMTP id 3A85118000C for ; Thu, 5 Jun 2025 22:39:12 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=AsTDUcH4; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf06.hostedemail.com: domain of david@fromorbit.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749163152; a=rsa-sha256; cv=none; b=n/ZVTiXq0tDq3iIm1cDtnKf+REpEJs+MqQLqVow3QyRgStrQsdO7aHc4q0MlkB9GKO1/kr DGErrpdHE8j/VosZJMjgVYm1DQGECTBU9hR0SPO0aNowNIuFPHMSNTYgXePnvJ6go5ecLc es8LS3HlZ3DjAzcAYkvSakcHqbdQeEY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=AsTDUcH4; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf06.hostedemail.com: domain of david@fromorbit.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749163152; 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=KVz4xpCWXUZUVgN7nhL4DpLQFRsJ3GTrIpQz5yuevBY=; b=FIQMyGNc6s8/q/L1qFJwiuQ62qY2Ffsa/nUSoTiGV+aKdikYuv2eJqOGhUkJEz8zCPX0k3 54wqA5SLOZgTa+0A1gSAj03+4AZ8sU4wsNAsym0Mjq7S/oDIaoElm0KIdEDnKnTFl8MlbZ EwUhFQyqvF6RJqAgykJkp3Ak75Opl+4= Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-73972a54919so1505257b3a.3 for ; Thu, 05 Jun 2025 15:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1749163151; x=1749767951; darn=kvack.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=KVz4xpCWXUZUVgN7nhL4DpLQFRsJ3GTrIpQz5yuevBY=; b=AsTDUcH4/xBQx0GSoRxK4R+qjvWQ42eQEk3A/W/8UUxVl6N24UD9KLfdJZp0KH1Yni YRB1SdhJlFIyFg3ukOhgHp13FvCQ0zmnd3LwoQ4/Mmdv1jOqbfa8PudiKkoosC+2xauq wfKJ/nZ6gGs7LV0scYlz6Ttu8xSOP/YrCl+BqxFcYyWkYHthKnA9PycUV8TWKxSukJ2l Nf+Temz+KlO2/3rmRddzUJ2uqNXRmGs2tsc9soamhuBeQ4GMBPHRVNqBc7G7+81SaVRn sW7FiZEgk0NN8camGcgG9pE9/zel/3vAw5Nmof5FBAp4QcVOCmXY5iCb69lK3oUEamZS OFWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749163151; x=1749767951; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KVz4xpCWXUZUVgN7nhL4DpLQFRsJ3GTrIpQz5yuevBY=; b=kDLAVkZrsXhQ6iNepr2WF+XQkG6OlnT1D6RHSd6GpRzN47WiUSqzgAcDt5x/mHwK0Z HJbPWISE8wGzGFBqA/S5v5LQBEl4h41efWwikDpP5rDamvtQVElUxXorsfiA1Dw8S8jU 8EvRJ3PwHyPizIbY3VJHKz9ARHPEWe461u6gvhVYCKJ6SMBAxI3MtxDlKQo7F2OPoKKk cMtI2a/eEpxtQwhbIw5Q17IlSbvDgZyY7P5bQhlV65CcMO9k9sjUK3D5WBcB8ABNEYn2 UWS2dxYhQoXzpLUhzVuIpgCC9Nth1uK3qeAqWfmSkzMEtI81Kt7aVv9pbDkVdfn82+cV BcSQ== X-Forwarded-Encrypted: i=1; AJvYcCWlC3m9zujpCMF7d6xrrLKaEJm23LGAkqO/Dxt70I2lvMJJ7dGzHjk5wN7yHx8yR5fz8DkEDPNFQA==@kvack.org X-Gm-Message-State: AOJu0YzK4q54F0wU9Ft6zh9JpGAhaA8XasYi3hSAbiRCWKfTr/QEajrs vooOo6KHLyB4cEY5NoEH5RNxNL2gFVHN2xesghr9x7e1yS+3NUQAGDgRcEFhMfVCzTY= X-Gm-Gg: ASbGncsdYJcQGXYmcFeklv/A5yp3cMk8XHRHP79brfSHaUpoM07X+jT/sG5maXyvTGX 51pc3YEmHrBlGJnei+a3mzYBo6fQOZkvetXYkfYgscTIftdx6fbK/spT9hZFTj4fDp6vjFn3kpt ke6a3Ly1ivSDt3CNgaEzasK+BGPEkXPiuhUBh7IBNFulXaIIY3297zIaEtWPH0N44oNaDh5RlY4 Ydztu3j4N0Q7HX+a/LuuyAHZELCUIyifVeVB36cX3gQc94sL7tv0HwY7m1YAuklxiqj6qEmuhkz 2ubRUpW3U1VfsstXV2itutbpjYHorIYoFe6Y/oXQ20UgXSHKaBtVCCnTOlfqd6tEEIjF1FYXBgb 5rwR0s93CIE2TO4+4rnJD2Wa1LceTmLthIBw2SA== X-Google-Smtp-Source: AGHT+IGTZb6ntJ7bPs5CTRhXptI5oJA9/k2lrO0i462LkFdhCVHOYHjd2TfVg2UTAW7xyGXUzbllvA== X-Received: by 2002:a05:6a00:cce:b0:742:a91d:b2f6 with SMTP id d2e1a72fcca58-74827ea58b7mr1694749b3a.13.1749163150939; Thu, 05 Jun 2025 15:39:10 -0700 (PDT) Received: from dread.disaster.area (pa49-180-184-88.pa.nsw.optusnet.com.au. [49.180.184.88]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7482b084f60sm168455b3a.101.2025.06.05.15.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jun 2025 15:39:10 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.98.2) (envelope-from ) id 1uNJEo-0000000Cjqp-3Koq; Fri, 06 Jun 2025 08:39:06 +1000 Date: Fri, 6 Jun 2025 08:39:06 +1000 From: Dave Chinner To: Dave Airlie Cc: Kairui Song , Johannes Weiner , Linux Memory Management List Subject: Re: list_lru isolate callback question? Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3A85118000C X-Stat-Signature: f93o9n7s4k93w3dc618efa4tk3gb1m1t X-Rspam-User: X-HE-Tag: 1749163152-948019 X-HE-Meta: U2FsdGVkX1+wbQcSSrNHDJ1bEKchNSBTcepvcGHqHw3SunEZmEWh/GSEMJepO/iFn6zWunO4yMoYJaIn7iw59xqVIvPdGbQg7WgFsX36e7tFi/URNZD8DoZCBxcr1p8wx23L0PonuFx5sa2Y/84OZz9i4NXqNnUWB052i06soHIEV6EfWXeVt79sgBUpvyDuOwdFqyb7ZlpUZ36C5FII/C92BZm2uW6CZCmJ9QBTjnM7UzxCmTnjdLNXflkzT2rHDHatIE6bvCbwSWTvQE7EeTqyaV/RLb4lGm5YP2Es05HP8Sl2xqEMDhCP+y6nfcFPyV0r2ZFRAavgyRmKE7SS2Axkq1/prhU85cw3u00EXYCNCDEd0nBzYhXwonyH2CB3QqVAW4WknRuiuZVlP3uRCizqhPngy7WPqPobJOjJiq7tujtojCB5ZeU5QIfklDSBoAvnDbSmI18TOd9zQ8nD0uFV7jNpeu67G3t1l2/SqCHAfhBgKLecNbu7mRPW68UCb6y4k0HTO9WzPu5v9SZ4IczwT7c5pKmOE6N6AzZb1AsLmg7zDsIcwVLgRrhZckkg5sTUqpswEs9uVhNFnbcPoGn83Hrn4MgorN/y/0QPat/oGqfzVs9sF3Java3asXfOoHCmm5wUBBsYy9KOZY14/pyE4bWm9cC0DncqD1AP4eT54hMS7tea57L3wFhl9YMyyDImQcirUqWT1Cnv5tEjeDsKMKSLWiY0EZxnh0zUmwH8fD/tCW++iBQRBIrA+cVaMHiWziCuF9GpP520iSsg8+6mEkqbhkC+r/kNFFTRm0okaDDNN4VMVT9wBLuXXoXBFzdL0nfcZgqd6/T9lq7S+g3y8OI7tAGizZR1gyc1sQBR5gowwnY8CQ5UZLWwxWBWIHVuG3GjNqPp3h7eeNFwIw+/gnbZ6lJb4Pi3MmN9FYK7FdwLL87TbpWgTd97VkoTf/GGtK1XtuAlwHgQuq1 R6OIGCYi SiOTJZv6bdjEPFbgsXdHkWPUQ40gQ0XPZ7pTZP04IJ5BrbCSW99FSQ4BTZfun/mPMGH5QOg26xrYq8ipumRD//A2IcmHvna6Jy/hFFCVJPpzMs31C/rTrgCuhHzK8tDQpPIYHv8hXpQQimoGLpMYgeSzbsyzz2a47PLyPlV49sOg2sOYM6NZ0PF2y21n1ij/uwm+rbCc8t3uLW5B8/VQpo2GIDhJM95OYcOJgueH2pp4gHoeg2w13DvkOfYypeeqMJKbAFGECekMOZ4+txqLTi9RPxgcVIphGJ5fk2pGneriUhThZ4NvvWn6Si1n1NBvK39qYgenqf5nim9ZYZUH72CsyruTwwTlk8F739pTQftauPTfpmZ5QvfAV4Jl+0fD7ufqBMZ8cJIdKxHaTuKTxSgK+NZQ9HIHoCSgqX6yLjUtadmriYkGiuKnWPuMNtSx9iXrBAI16IC2g9uhhhUbwL5v5qhI3U/8NYnfesePFm8XKzdI3Um3Yt8ARj/UtoydF45vF/YLyerHoUDJOU9T+eSW6IriTmFlZDaPQ0riO0/ongj8= 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 Thu, Jun 05, 2025 at 07:22:23PM +1000, Dave Airlie wrote: > On Thu, 5 Jun 2025 at 17:55, Kairui Song wrote: > > > > On Thu, Jun 5, 2025 at 10:17 AM Dave Airlie wrote: > > > > > > I've hit a case where I think it might be valuable to have the nid + > > > struct memcg for the item being iterated available in the isolate > > > callback, I know in theory we should be able to retrieve it from the > > > item, but I'm also not convinced we should need to since we have it > > > already in the outer function? > > > > > > typedef enum lru_status (*list_lru_walk_cb)(struct list_head *item, > > > struct list_lru_one *list, > > > int nid, > > > struct mem_cgroup *memcg, > > > void *cb_arg); > > > > > > > Hi Dave, > > > > > It's probably not essential (I think I can get the nid back easily, > > > not sure about the memcg yet), but I thought I'd ask if there would be > > > > If it's a slab object you should be able to get it easily with: > > memcg = mem_cgroup_from_slab_obj(item)); > > nid = page_to_nid(virt_to_page(item)); > > > > It's in relation to some work trying to tie GPU system memory > allocations into memcg properly, > > Not slab objects, but I do have pages so I'm using page_to_nid right now, > however these pages aren't currently setting p->memcg_data as I don't > need that for this, but maybe > this gives me a reason to go down that road. How are you accounting the page to the memcg if the page is not marked as owned by as specific memcg? Are you relying on the page being indexed in a specific list_lru to account for the page correcting in reclaim contexts, and that's why you need this information in the walk context? I'd actually like to know more details of the problem you are trying to solve - all I've heard is "we're trying to do with GPUs and memcgs with list_lrus", but I don't know what it is so I can't really give decent feedback on your questions.... > > > resistance against just adding them to the callback? > > > > I'm not sure about the context here, I personally prefer to keep the > > function minimized unless necessary, so things like !CONFIG_MEMCG or > > single node builds won't have two dummy parameters here, and > > most caller won't need them, the compiler can't optimize that > > out IIUC. > > I reconsidered and was wondering if > > struct lru_walk_args { > struct list_lru_one *list; > int nid; > struct mem_cgroup *memcg; > } > would also be an option instead of adding two unused args. The walk function is passed a struct list_lru_one. If there is a need to get the {nid,memcg} of the objects efficiently from walk contexts, then we should encode them into the struct list_lru_one at init time and retreive them from there. -Dave. -- Dave Chinner david@fromorbit.com