From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 3ADB0883F for ; Tue, 7 Apr 2026 23:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775604964; cv=none; b=ZH367DXwh12sNrVb+C3ta4z/GvvBRnXa/4ZvEhcK9UK2KqiZR4paKcjGmBSb8lit3bmCWuqhqCrRPKwizRiOnAXWiRuITIQ2VaZ0MkW5s/Zivd6wpxnUyrs6wbN2gSa754B0Fq8Iul6T5KRcP/SQ40eQQeQvZNVqJSz1XgTlPH4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775604964; c=relaxed/simple; bh=J2rNnxlWqh3SsVU6sZOyJgU6R/+22IABqsvYI8Pw4F8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rj8rL5GblCS2Xc5BCd9oqWKxBHciorosMjk+HaZIu8H6dRqFeREDPshW8wEe4nEE1a/9CWJOz2scvg5XDJq/gF/OpwEObJ+oZIq/WtrNZGiJFKs3bgpArAFXqF8mZRNecjsMV2+t8g+Tvt6YCHYzDHX07Wb643O6thTP72RWU6I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gzwV2I2n; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=VTHezU2E; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gzwV2I2n"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="VTHezU2E" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775604961; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cSte9vRO1TSshWcFHdBwTd4rL0Ri6sBQhlLf+reom5g=; b=gzwV2I2ncUaqe4+QeLgjoWkgtjPeLfmFpCTr4rwSDxK4lI4btnWMqUO++NzW1aPp4fp8Ow WP8R4m4Jnvezxs8mFvTp60v/XkbRv16gtk2CR58hFskdBBfdyVr21kon4pDLTIVBCGJhjL 1wglG0RCTCdDy3ecrqUPW8SFVaGvM7E= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-622-VuL3EoTeOkqsewaRo2CVdg-1; Tue, 07 Apr 2026 19:36:00 -0400 X-MC-Unique: VuL3EoTeOkqsewaRo2CVdg-1 X-Mimecast-MFC-AGG-ID: VuL3EoTeOkqsewaRo2CVdg_1775604959 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-50b4b81c632so144967871cf.1 for ; Tue, 07 Apr 2026 16:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775604959; x=1776209759; darn=vger.kernel.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=cSte9vRO1TSshWcFHdBwTd4rL0Ri6sBQhlLf+reom5g=; b=VTHezU2ERa5vLLY1bNeRrOzjrI3k7jPjHqDkuhy977AZgKMX8vzZxMkRgRmkdRztku kLW9bB1QuZiG0zCJLyAdOLLxHK9NlKKVJlBs9LGZCyP3fYYUivkYgJzr03aN4relF+1P WISzyba4RUH33eJHz53k7aBSMgBUf3txEjYcS3yPxIbhN026dCU/aeXivz5rf99BntKf H4o1BfJuLqsT1mAcFXnN4Q8LWouYO6lZCDKB1LQ5xAXZJG02plu6ZJzkr7C0qMiWwIID 3MzPe516YkSSn0m458wmlve/0tADo9W6XmH1sW1tLfhtEN5xk7gnrWS9vuheYNcB3geX aP5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775604959; x=1776209759; h=in-reply-to:content-transfer-encoding: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=cSte9vRO1TSshWcFHdBwTd4rL0Ri6sBQhlLf+reom5g=; b=oWdGMsnKrIH8rlxkC2W74PvAfsMFGuCuzL3R2NqwG/0Q+Rjq2/CJ6mGczxTzF4bXyH 3NfF26m7muKIiaaqQYN9gWDhEJQyUL9b5Dr/FUeZFfS2dE2KIf+5AuGq2jSTfvtxxxN5 QKA0hrmTDPyD7TOgSIOU2sSbqCKALx0fTNaVlyom30aZMQ551/yrWTYmJRRdwZWL/0o2 BkLxsY7sUmtSv5bYOhuTnqCZ0I0H2MI+/w15NWUihq4nwPUjphGcWDmaDm9r/fw1uWXG K378OWnjGzC73Mkn4W+9Y7vAT8F/BadAQwkXYltfMFIVTtAWzaFn8TNH6MmJw7TtmIWg riQQ== X-Forwarded-Encrypted: i=1; AJvYcCVN6oDemROsfsyGEVyHvPwxtwx5nnyd//VyiQ07uSn3QWwRK4tXGdy0F2hf34bR1rHEOpySqTZPqZOs60k=@vger.kernel.org X-Gm-Message-State: AOJu0YxemRGvzwOYKgjSV+SEPW3eYVL8CBz8e9TM7YOwICv9scoicm3V 2uPZ9uIy0Zh/AndnbE5eWitnbeL/pnc5nJzCGlvky73JL98E38t982UwIBYux0cro7jM1R8xigX uL8k6QWlsgNUPboiWoink0dV1ECOhUKOlIqbKUa1Ac3DeBIq2BznEP4sG21PDh3hsQw== X-Gm-Gg: AeBDieu58/+45OUA4PYjeG/bAQXfQnm0CqvzWgr+L1SbMsy5fUUT3oogIsKAKxL704L LT3PR7/noq+Zb1tHuigoBqIW2OrlzB+2NfudbJMybeJS+veu/VDX7hHjbomNopUr7RzF2LRwHL7 dexx2E8T6fsyZuLIOKtSRmwdQ42NZur7oSrygBXhIXamE14XnErKqV4y6t129l8U/kHwzTuOiV1 WViAREeQBHxqLVf3ZdwhpEIzwZufHwS+Hnn+BRwqsRPJl7qp4Swc0OutQCxGAy//X+o9tJP7Iv8 fht1aWSednsHA52pOlppDVppeBLPE325tM/0eNZlZDmXEEwG9eUh30yyPwwQCvjSEtYH9xgE/28 rrYhQ5DByiOJ81LnD18oaiuIsbFVHANyUK8tWCKgUk5NbHDfpNE1teLYp+khiE8M= X-Received: by 2002:ac8:7e89:0:b0:50b:41b7:d6c2 with SMTP id d75a77b69052e-50d62ad8295mr291701031cf.47.1775604959232; Tue, 07 Apr 2026 16:35:59 -0700 (PDT) X-Received: by 2002:ac8:7e89:0:b0:50b:41b7:d6c2 with SMTP id d75a77b69052e-50d62ad8295mr291700461cf.47.1775604958598; Tue, 07 Apr 2026 16:35:58 -0700 (PDT) Received: from localhost (pool-100-17-19-56.bstnma.fios.verizon.net. [100.17.19.56]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d5ea136a1sm129517281cf.25.2026.04.07.16.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 16:35:56 -0700 (PDT) Date: Tue, 7 Apr 2026 19:35:54 -0400 From: Eric Chanudet To: Michal =?utf-8?Q?Koutn=C3=BD?= Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Maarten Lankhorst , Maxime Ripard , Natalie Vock , Tejun Heo , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, "T.J. Mercier" , Christian =?utf-8?B?S8O2bmln?= , Maxime Ripard , Albert Esteve , Dave Airlie Subject: Re: [PATCH RFC 2/2] cgroup/dmem: add a node to double charge in memcg Message-ID: References: <20260403-cgroup-dmem-memcg-double-charge-v1-0-c371d155de2a@redhat.com> <20260403-cgroup-dmem-memcg-double-charge-v1-2-c371d155de2a@redhat.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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Apr 07, 2026 at 02:48:05PM +0200, Michal Koutný wrote: > Hi. > > On Fri, Apr 03, 2026 at 10:08:36AM -0400, Eric Chanudet wrote: > > Introduce /cgroupfs/<>/dmem.memcg to make allocations in a dmem > > controlled region also be charged in memcg. > > > > This is disabled by default and requires the administrator to configure > > it through the cgroupfs before the first charge occurs. > > This somehow dropped the reason from [1] that this should be per-cgroup > controllable. Is that still valid? (Otherwise, I'd ask why not make this > a simple boot cmdline parameter like cgroup.memory=nokmem.) [1] argued it should be controllable per dmem region more than per cgroup. For example, a cgroup configured +memory and +dmem with one region charging only dmem and the other double charging memcg and dmem. cgroup.memory=nokmem karg would double charge all or none of the regions for all cgroups iiuc. So maybe just make memcg CFTYPE_ONLY_ON_ROOT and inherit that configuration in all children would do? > > @@ -624,6 +656,13 @@ void dmem_cgroup_uncharge(struct dmem_cgroup_pool_state *pool, u64 size) > > return; > > > > page_counter_uncharge(&pool->cnt, size); > > + > > + struct mem_cgroup *memcg = mem_cgroup_from_cgroup(pool->cs->css.cgroup); > > This is not necessarily same memcg as when the dmem was charged via > current (imagine dmem controller to depth N, but memcg only to N-1; > charge, then memcg is enabled up to N so this would attempt uncharge > from new memcg at level N, possibly going negative). > > There is a question whether dmem should enforce same-depth hierarchies > with `dmem_cgrp_subsys.depends_on = 1 << memory_cgrp_id` (see > io_cgrp_subsys for comparison). Thanks! I'll look into depends_on. > And eventually, if per-cgroup attribute is desired, it would make > greater sense to me if that attribute was on the parent level, so that > siblings competing among each other are always of the same composition > (i.e. all w/out dmem or all including dmem). This likely results in this > extra-charging attribute to be properly hierarchical. > > HTH, > Michal > > [1] https://lore.kernel.org/all/a446b598-5041-450b-aaa9-3c39a09ff6a0@amd.com/ Thank you for the feedback, -- Eric Chanudet