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 170C8D3C92D for ; Sat, 19 Oct 2024 22:46:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 841816B008A; Sat, 19 Oct 2024 18:46:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CAAB6B0092; Sat, 19 Oct 2024 18:46:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66ABE6B0093; Sat, 19 Oct 2024 18:46:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 468D06B008A for ; Sat, 19 Oct 2024 18:46:09 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6339BC0EC9 for ; Sat, 19 Oct 2024 22:45:54 +0000 (UTC) X-FDA: 82691836080.12.1BE5D42 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf01.hostedemail.com (Postfix) with ESMTP id CECA540011 for ; Sat, 19 Oct 2024 22:45:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="X0J/za8R"; spf=pass (imf01.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=joshua.hahnjy@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=1729377816; 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=HygObp9ZtTiCt4ruecN7jyPhUDu4WsEXYehExPiGj6g=; b=IUbV93ExQKHXUKGmYED3jGqJMuRjs1JO1M4cyK5au8D1xv8LnkBePGyOaH980pS3RFNwwp imsZpF8/bHSDsuv9uUVQSI+MmqGVou1cbeUVSCAtOM5GVY7A379l8I6SthoyRjZXIofcXY RAL+pyywLn/cpVFaMKLEoFffLMnE2PE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729377816; a=rsa-sha256; cv=none; b=J2XwnMNbDK1cMZ/W1zl0q+5y5Fkv/tEA/Aq8G8pT/507FOM5dj/SFk1rxyRIfZ04sIqK9O WmCMb1S+LG6rrTYxvrL7hwybs31obr+vDcfoO8/hqM+nhkbSH+2brmG1KX7O/S3XZeosnt f6wRJ+YCgSWD5jHpxaK2Rnsb0xnfJg0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="X0J/za8R"; spf=pass (imf01.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=joshua.hahnjy@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5c9428152c0so4219355a12.1 for ; Sat, 19 Oct 2024 15:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729377964; x=1729982764; 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=HygObp9ZtTiCt4ruecN7jyPhUDu4WsEXYehExPiGj6g=; b=X0J/za8Rs5T9iGur3FVRnSkYaUf1hq97bmSKMlrKp+SrLYxMwJOSyRRZZe/kgYiNh4 mh4yi+Xtc/RYV8K0pg/RZjZdreIH0KD+DRRxdrtjBMr/jmadGqk/IX9kzv5ROHzTUi+/ A0MaOU2XbUapDT4F5lfsis5KELwIsuENuKT6CgYpNrs70yEDJhXuRuiVmEUMFxlM6hHO 6p4kapqrEJIA1dD61AgFh5kzR6hyvKOyLkweG+ejTOinyss8a+uy+oPulpDdN/sUy/M2 rwusSbvfpT+7fC8L0mvsy7LD+qQrgMADdGuAnbN1B9cRFKvjbOIBEYO8D4C9fJrAigTm sRkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729377964; x=1729982764; 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=HygObp9ZtTiCt4ruecN7jyPhUDu4WsEXYehExPiGj6g=; b=KpY7Rnak/qUmP+spLeHoZ/xgKJoP8SK7va/6xK5LUnB15hzNQfqwGsK2R+M5TuXHHv /LeBa1dzqiL27BNWKkQOlv/KTFg1lUvpeBibrVrIEWk2yjHP8Uh8P9Mm5mwf5zIH3CU2 RtJEiVGmy+x5M+g9EDbimcNBujk02MqL1/puOjvsjUJjz+6MTMNhISOZzF3yge8/oaeW t61RQTJiJ8FYbbYn31LsqyAsfolWtPyKEgJhFNoq3J9Slx2IN7gO3EByFMbKUo2g42gU tOv8feCluFQ0FSlMirRMdSx2N4SCC5+qsc2lB10esWqNb64A6mvwW+UjFq6Zhd4ubF4P HKtg== X-Forwarded-Encrypted: i=1; AJvYcCX9oisMn2/64X6uNdnveNZvC9ehKiuHXzuEFU3oQ1SzFKETKgjQoEmDG9mQeGXUeHNYI+upWjp3eQ==@kvack.org X-Gm-Message-State: AOJu0YwSK3YFx+jOiAnIeh/e+Mqx3+5QZjVn9EU/dE0anq07/x1kWCs2 /CSz49Yj/6iAeO/WCyKjrE4Uu+ggcVTaMwpQf8jfOVqpH/7Do9Jzz49Sbl6VpzzUiHyMsdM6iIU 1pYBiXq3mn6mSg2rtMotdQvd/D8k= X-Google-Smtp-Source: AGHT+IFAOoB+M7JjlLl7z0ntzCkGcHgGblt5gwhJG44WUxgPDR/KmYf5vV2JDcbJ5hpyN7kRwnm/R9a7HRoJZpMaskw= X-Received: by 2002:a05:6402:27d2:b0:5ca:14f3:2883 with SMTP id 4fb4d7f45d1cf-5ca14f328ddmr2611149a12.4.1729377963447; Sat, 19 Oct 2024 15:46:03 -0700 (PDT) MIME-Version: 1.0 References: <20241017160438.3893293-1-joshua.hahnjy@gmail.com> <20241017160438.3893293-2-joshua.hahnjy@gmail.com> In-Reply-To: From: Joshua Hahn Date: Sat, 19 Oct 2024 18:45:52 -0400 Message-ID: Subject: Re: [PATCH 1/1] memcg/hugetlb: Adding hugeTLB counters to memory controller To: Shakeel Butt Cc: hannes@cmpxchg.org, nphamcs@gmail.com, mhocko@kernel.org, roman.gushchin@linux.dev, muchun.song@linux.dev, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, lnyng@meta.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: fy5bkxeps6xbyq1k48u6wj7zf3drn5dx X-Rspamd-Queue-Id: CECA540011 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729377954-870284 X-HE-Meta: U2FsdGVkX18l1A67nmX5y38kJs3qwO+gNhOca08iZMwrR9tI4MnRFQjVwKrXpzf6I2XAmHFeaqFbU5TkmPLMCC6N+ujkPOtmpNZflAj2f1Vh5k3PMrDVVG6s8d01RPxeb/fKJXLuCRw1DzdMtRuGfaaCHBiBNO0hiN5HGe2O5aQfN7pt1mXeNE1jqewpyL8R46IDlzT6NCWSG8KAMXIMhZpi4orFVa79hfgerJj2bTp4MKRNiFNCmM2HaG6KkEcICDVMeRmClg43rre+oCK53bwg6G/rn6B7EfT+Kfx0t8UU7mIfFD1ZCVoQ1ssY6hxtz4bBZN5PujYztMpEkl6f6/AAuxt2l1y17VQxIWMx1u+6k3nir/oXeZDGikCTUEvXjJm1MzqSVhVa0Nit3A1Xnl/vYaQU04bRDDpqgGmyHQhdzDSrt3dt0MJUKcJ/XupUhdkXj38z6O+xnbuKrfObRVw2LLsjN+4oTT9WdjjyxZqECa1tfRSm246uot02UFhc/++w+156Cfgar+ngr/2NtzLmkthiY5QXvacpobYUI5FUHbNVnnwXr5+5PZWQuKwbNwfWYL7b0CEc7eHyKVWqVenTPSkBb+pKSW6eZZpgoE30D9X8Oyh5BAWdMpgKiAy1qLAo4h4hbFNfeqDaxgL+LO08/ITFKE5N4k2HjxW40UaulDWKGCVHz31Cldnetzhn5jyeLFHuZy7h9hJDR8rL2gtyx8z4hk2VZKXx6JszMNzjoRVA1z314+sXgRNONG07yK9xJfraF1HvQW4ffJfYyRxjAZ4oDoQIFPQpDxrf0r/RZpcp5tV0IKxFQ2lgjCuX+EeDXzyiZdIyogEjRWccNLdrdwwB9cPgpRzo2AYFiVPL2h7JLGHxvGik0tWie4B5feI7kJBhciFWogbB24R6wdnkebyOuVjsTLXjMe65bJRFt+6DeqFrKcAkn/4mX4jztmQiW5RyYYpv0BV4T/G nTOlEZDS yL4lz5M17Rg1cD49lYUpH8Z1M+I/GNQxdruLwvKRgXTE/nnqkYbzuatmevEHL8JBDIkVbxQ8b8H7FPsz7I8t9MMgr26zqMAW1n2Ku0GgC1WsbuohmkvVETvdnvGzm38zpq3GM8bPEjcDhs7aB+AP9uXVzYGmHYNHHjDJLH1Sx9t1V0MiY8AJtaPzo+VjyYfeHB9fAY+s1Zwic4GT7YydUYwBoD/Vg48re3MmDo0OvxhWyxFYCzTU0N23Cw2t0G4JtyywG6H4aPqRAj7piFT6+m1yLvopdhob1eHw6koBHUYdBbKgpxK2sT1P1pezNY9msqiuAmvv0V7PIFDxFR/V7zonuozEnpaMbu5QbxBYOdjN3zQqEAkwd3SqGxg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.004801, 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 Fri, Oct 18, 2024 at 5:34=E2=80=AFPM Shakeel Butt wrote: > > On Thu, Oct 17, 2024 at 09:04:38AM GMT, Joshua Hahn wrote: > > HugeTLB is added as a metric in memcg_stat_item, and is updated in the > > alloc and free methods for hugeTLB, after (un)charging has already been > > committed. Changes are batched and updated / flushed like the rest of > > the memcg stats, which makes additional overhead by the infrequent > > hugetlb allocs / frees minimal. > > > > Signed-off-by: Joshua Hahn > > I have an orthogonal cleanup request (i.e. after you are done with this > work). Hugetlb is the last user of try-charge + commit protocol for > memcg charging. I think we should just remove that and use a simple > charge interface. You will need to reorder couple of things like > allocating the folio first and then charge and you will need to do right > cleanup on charge failing but I think it will cleanup the error path of > alloc_hugetlb_folio() a lot. That sounds good to me. I was originally planning to include the hugeTLB accounting in the try charging mechanism (as to only include it in memory.stat if it is also accounted for in memory.current. I will think of another way to do this accounting so that cleanup becomes easier once this patch is finished. One way I can think of is just to check for the hugeTLB accounting config before adding the stats and accounting for them. Thank you for your feedback! Joshua