From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.111 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794559828; b=gKAT3h4dT1hWWGPbETkECp4nyzsR4T40AhMeo8zS5Byb58ctZdxImuYQ1kBzjJXc5e5e Ns78AO2gqP0m9XaNj7HvXq/CYT8T/wufSbbNWEQzWQSL+C/2JgZLHhLlf1LmGwPWY8MN7 +OG8mPm/9MdjYATGfhWMRipfH/NMj6HPQ3DRKq42z2zTV/BYI/ISCIapG1UkNwNcH0Xr9 5+3FUD5DORvq0vR1BnpMk7zlWJ6P5OLNuJexNOdXRokor3r13uO1XO2TqQGit4T8HODhF KPgNys46jBIo1nYVBW4NxusPbUjzADXsSNgniuOQGy28vlsB22v1P/BNHotQXHlew9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794559828; h=DMARC-Filter:DKIM-Signature:Date:Mime-Version:In-Reply-To:X-Mailer: To:Message-Id:Content-Transfer-Encoding:References:X-Original-From: Content-Type:Cc:Subject:X-Lms-Return-Path:From; bh=BRtBrIkCJ4EaL32K9DlOPnqwkNfnHFCSjQCoKgoeAeI=; b=Wd+xyGUQCVYNN57LaIZr8a6cIRgc5/ob1rae6BHqhOeJByrnTS9vFkJPSsxijWNIo8rl ukN0r38PDNZtBJ8to6/xmGzMJazxayi0Brky3Kghk3R/uoVtWvrnVFcDZCF+Gxbx+kzIl j+FkTXEIBLMgn5srm38dICWAYtFPWkRdHpFOEPGsGv6WqOzHrm7qc6K5TvI60nP8pAFMv uyP6OKkInPVzmudNOkM1hgzfJLhw5T0oVQ9+IsfqtQTfN/pKyIQTVNUiHhhlHLuQ8xEtU ffq9EyyPXHR4KBsO/E2zyv/ey1ogbEgs+BPTyUG6hgeBwni2sVftFfawZNxZfw/uqeg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=2212171451 header.b=Rmrg7xnK; arc=none smtp.remote-ip=209.127.231.111 Received: from va-2-111.ptr.blmpb.com (va-2-111.ptr.blmpb.com [209.127.231.111]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1CB6606A33A for ; Fri, 13 Nov 2026 08:50:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C1CB6606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=2212171451 header.b=Rmrg7xnK DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1794559824; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=BRtBrIkCJ4EaL32K9DlOPnqwkNfnHFCSjQCoKgoeAeI=; b=Rmrg7xnKYuZTpGzOpvufLixsjzkgqeyHnS7ghFxk6Q8rFuldGz2kUzdl4nsJEdVcDVZzIr ZYEmoaR9AwfTPQ6rcTXIgjO/hKJAjptAVV/+ABf0QIKyRWlGZwf+v22+L980XUQIUPpmNa vurCWKK9Bo1e+Vj0KQKP2o9KqvHzToPRBtEbE6S2Ohaca7EYjdI/qkzxag4SG/djIAYLNp 2f12cXNSdfOrOE7TZ3nflYnvtNskoXIBZk5rjjAm5vHXdyM3GeeO5bH/nhSmSw5PvGFIih hOvj0zj1AgbnhpP0oiYGp1q36y6jHNaZ5nW9HiwnEHuD0Z/M38IeCZ5CROMO5g== Date: Fri, 13 Nov 2026 16:49:48 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 In-Reply-To: <179455442014.482102.4069329165987986914.b4-reply@b4> X-Mailer: git-send-email 2.45.2 To: Message-Id: <20261113084948.78661-1-lizhe.67@bytedance.com> Content-Transfer-Encoding: 7bit References: <179455442014.482102.4069329165987986914.b4-reply@b4> X-Original-From: Li Zhe Content-Type: text/plain; charset=UTF-8 Cc: , , , , , , , , , , , , , , , , Subject: Re: [RFC v2 1/1] mm: add source selector to memory.reclaim X-Lms-Return-Path: From: "Li Zhe" On Fri, 13 Nov 2026 02:20:20 -0500, gourry@gourry.net wrote: > > On 2026-11-02 15:04 +0800, Li Zhe wrote: > > + Specifying a source value constrains where proactive reclaim applies > > + pressure. Currently only source=nodes: is supported. For > > + example:: > > + > > + echo "1G source=nodes:0-1" > memory.reclaim > > + > > + This reclaims memory of the target cgroup resident on nodes 0-1. > > you buried the fact that you want to allow source=zswap in your cover > letter. I was confused by nodes: was needed here until i re-read. > > As Joshua mentioned, i don't think you need the separate cover letter, > and I agree this is far too long for the proposed change. Agreed. The nodes: prefix was meant to keep source= a typed selector, but I made the motivation and possible future extensions too long and distracting. I will make v3 much clearer and shorter, and keep the focus on source=nodes. > --- > > When I asked for testing, I wasn't concerned with the functionality, > I was asking what problem this actually solves. performance? fairness? > > Shaping the distribution of memory is neat and clearly works, but why > does userspace want this? > > The interface "lacking flexibility" is not a problem in and of itself. Thanks, this is a fair point. Sorry, I also made that earlier explanation too long, so let me summarize the intended use cases here: https://lore.kernel.org/all/67fcd8db-269d-43f1-aea2-8c41165747d0@bytedance.com/ In short, performance, fairness and cost are all part of the goal. One target is mixed DRAM/CXL systems where user space keeps each memcg near its own DRAM/CXL resident ratio target, based on the workload's latency/throughput and cost requirements. Another target is the case you described below, where user space wants memcg-scoped reclaim to apply pressure to the desired tier first, rather than reclaiming from warmer memory on the top tier. This is especially useful when a memcg is close to its memory limit and user space wants charge-reducing reclaim to start from colder/lower-tier memory first. > I CAN see why you might want to proactively shape what data is swapped. > Let me give you an example: > > --- > The global node reclaim interfaces allow us to put pressure on distinct > nodes - which lets us shape which node is swapped from first. > > Example: node0-1=DRAM, node2-3:CXL > > echo 1G > node2/reclaim # swap from CXL > echo 1G > node3/reclaim # swap from CXL > echo 1G > node0/reclaim # demote to CXL > echo 1G > node1/reclaim # demote to CXL > > But the memcg.reclaim interface only allows us to pressure the complete > set of cpuset.mems nodes for that memcg > > cat cpuset.mems # 0-3 > echo 1G > memory.reclaim # makes progress from any of 0-3 > > Presently, proactive reclaim iterates nodes in node or fallback order, > meaning it attempts to make progress from the fastest node possible > first - which attempts to demote by default. If the lower nodes are > full, this demotion will fail and we'll swap directly from the top tier, > which is (presumably) warmer than the bottom tiers. > > Enable source-bound reclaim in the memory.reclaim interface so that user > space can have the same control over memcg memory tiers that global > proactive reclaim has. > > echo 2G source=nodes:2-3 > memory.reclaim # [z]swap from CXL > echo 2G source=nodes:0-1 > memory.reclaim # demote to CXL > > This lets user proactive reclaim to target the coldest memory first > rather than preferring to reclaim from node0 first and potentially > swap out memory warmer than what is present on a CXL tier. > --- > > With this, you might be able to demonstrate fewer refaults and less > DRAM (node0) memory consumed by zswap. These are clear benefits. Thanks for the example. It makes the problem much easier to discuss. I will refer to it when reworking the v3 motivation, and will avoid framing the issue as a generic flexibility problem. > I would argue that memory.reclaim should operate this way anyway, > and that would could make proactive reclaim do this by default, but > I could see the policy bits in userland being useful as well > > Performance may not be the only reason you want this, but you need to > help me understand what you're trying to accomplish. Thanks again for the review and suggestions. Thanks, Zhe