From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (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 42B801D61BC for ; Tue, 24 Feb 2026 05:44:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771911858; cv=none; b=REUhTUucnjqFybJPA9dwgBqDMJwaXir+SuyBlFb6L5r2zn0xRt100dfaMpdc1uUXP6ESA3wlqYpmCD3RFT6bjNzqtqHtjAyHF4QtTrFLB0IRWoj/wtRtKlZxj5i0/K+q+Z5q9wLaDBn/FhyDE8MdRjB8hIrUGTSH4zbGhiol+TY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771911858; c=relaxed/simple; bh=rzK7GNSJ6eLbNqtPeTcBCWdyH8w/WzG0B6zkmRX1j94=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gQ+l9G5+VRw6fnB9BeSu0rMnvSDRLB3eGBd8xq33YoBvZlzN+yqBqpQyiZp1F5MNUH6R5QQwp8FEPTXXo7OvSwn8ITndJlECHRxNV6EyFRyGu4kmAuhgnp8Nsxspqsm7ST4PnJ8S8RJ7gCehcvXjhMGoq7/VOT/eBkV1TrSLQy4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=e6L8/GT1; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="e6L8/GT1" Date: Mon, 23 Feb 2026 21:44:07 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1771911853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UDiN5/pgIKNGFEPeeKgrUiwMTxAa7uwUxPs6Mze27+s=; b=e6L8/GT1w+S0WHuke+elD6HX1fCEaenrz3zCvyh3NXASLHKqK9yOcMYaviWPPxQ9i3CM5l S3uG94ZZqGDNz2MHWTWR/eWKsrNBV6PzHFtCZXDUEKKGD6SKd9YvxkeWJdzfjzqwm2nVnH blglS5BubzOu697v/+JyZGkuED/kCIM= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: kasong@tencent.com Cc: linux-mm@kvack.org, Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Zi Yan , Baolin Wang , Barry Song , Hugh Dickins , Chris Li , Kemeng Shi , Nhat Pham , Baoquan He , Johannes Weiner , Yosry Ahmed , Youngjun Park , Chengming Zhou , Roman Gushchin , Muchun Song , Qi Zheng , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH RFC 06/15] memcg, swap: reparent the swap entry on swapin if swapout cgroup is dead Message-ID: References: <20260220-swap-table-p4-v1-0-104795d19815@tencent.com> <20260220-swap-table-p4-v1-6-104795d19815@tencent.com> 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: <20260220-swap-table-p4-v1-6-104795d19815@tencent.com> X-Migadu-Flow: FLOW_OUT On Fri, Feb 20, 2026 at 07:42:07AM +0800, Kairui Song via B4 Relay wrote: > From: Kairui Song > > As a result this will always charge the swapin folio into the dead > cgroup's parent cgroup, and ensure folio->swap belongs to folio_memcg. I directly jump to this patch and the opening statement is confusing. Please make the commit message self contained. > This only affects some uncommon behavior if we move the process between > memcg. > > When a process that previously swapped some memory is moved to another > cgroup, and the cgroup where the swap occurred is dead, folios for > swap in of old swap entries will be charged into the new cgroup. > Combined with the lazy freeing of swap cache, this leads to a strange > situation where the folio->swap entry belongs to a cgroup that is not > folio->memcg. Why is this an issue (i.e. folio->swap's cgroup different from folio->memcg)? > > Swapin from dead zombie memcg might be rare in practise, cgroups are > offlined only after the workload in it is gone, which requires zapping > the page table first, and releases all swap entries. Shmem is > a bit different, but shmem always has swap count == 1, and force > releases the swap cache. So, for shmem charging into the new memcg and > release entry does look more sensible. Is this behavior same for all types of memory backed by shmem (i.e. MAP_SHARED, memfd etc)? What about cow anon memory shared between parent and child processes? > > However, to make things easier to understand for an RFC, let's just > always charge to the parent cgroup if the leaf cgroup is dead. This may > not be the best design, but it makes the following work much easier to > demonstrate. Please add couple of line on how will it make things easier.