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 2D3AAC369C9 for ; Thu, 17 Apr 2025 20:10:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F352A6B02AC; Thu, 17 Apr 2025 16:10:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBDC46B02AD; Thu, 17 Apr 2025 16:10:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5DF76B02AE; Thu, 17 Apr 2025 16:10:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AFADA6B02AC for ; Thu, 17 Apr 2025 16:10:21 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 76A68C04BF for ; Thu, 17 Apr 2025 20:10:21 +0000 (UTC) X-FDA: 83344627842.21.4DBD38C Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf02.hostedemail.com (Postfix) with ESMTP id 8599780003 for ; Thu, 17 Apr 2025 20:10:19 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FlC1llQg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744920619; 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=UZ9CzFa621uATTSaULP4s96x8JmFYzdGBES+TbEIHRE=; b=7YJAN87UOVzcAWBq1pEybPpohNze0PyaE19GL8tTAMJZI7SaCHswmQmo2xYeoXnL0B5793 h1IG3obHgUq9pNUqKo7YLP3ot1eU1fv4fen0z9xG695Jl0wTw9U249MN1G3iOf282cvhwv ae5JtmMEOwbFO8ry0yAbuk2SM7M/Xao= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FlC1llQg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744920619; a=rsa-sha256; cv=none; b=L82kY3sskq7aAg4dHUxqteCEvNCit8jtSSAFlB/Mu2GEVCV2MWWL+bp6MoyJ+us0zZZK45 FRwG4vBT66PuSN5aAeg9/y0j+6k9yHGOtQIeUvp/L9aq7TH7wuuwLk9VZIQDZk0cro2vL4 2bwrxNcbEilvk6mZhhFPjnDVS1pKao4= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-22c336fcdaaso15379695ad.3 for ; Thu, 17 Apr 2025 13:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744920618; x=1745525418; darn=kvack.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=UZ9CzFa621uATTSaULP4s96x8JmFYzdGBES+TbEIHRE=; b=FlC1llQgFUVm0P9KxsgzdenjvUTbGnCiXKMCBicZPuj6NbfT2GC+p4l7APIOVrSxiY agaGsm/A0hs4wdhhHupuUEa1gZ9Lyv3aF6cmDrH7enrsDlbrHEl0lI+G1TXGVrijHek1 bEi4DkrOltWmuK71bd0wF9w0mT/QEIQbOf0vn+JQGuiN012Hw1vxYBVpRCfeMFAywJgb 865hB+oFl2EhhOV/iIfeGtK03MEQqZc3ldzLJVdSA6hK0QlFZzvua1oleko55koyQ4IL fDm7O7wVrgWZH1JsKyby075oSJUC3fErZ6uVJdcclV7gko0oQfW/Rqw/NW6lrb+mYFV1 K2hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744920618; x=1745525418; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UZ9CzFa621uATTSaULP4s96x8JmFYzdGBES+TbEIHRE=; b=ZykSswuRIDTj05FcxcaEn+lp9VspfyxJJp4DujIqlvF39giuRi06nhCxOkzTw+y1IJ VjmB2LYYLysN+pWtPz51Disst1tLXvSMwdiT4MPS49QkgmoHRl/LcRssc3CbF7OcMfl/ WN6Jc7ZQhnoq7SbnbAlpaVJD8lKjC9J9ECXWRZUi00ymAVRvomySCLpX6fvK4sqkWKLq Nd2QiO/a99T/SOB9Z1EyajQH8i+Mp1wTTD0GwRV4FP3w5aT24ofTWPwz4gi6yltrH4YD 4p/7K5Zixut+ew98MG15lp/itXVsAthVXGpruvwDVHPpDH51yq5kWS0beM8HvwdowIoS 83ew== X-Forwarded-Encrypted: i=1; AJvYcCVaYZph+u+ehd6NvRFjVCmNtIx1XTOUdelFR9V7ZFb1SNYRRLwdbql2wqYJD495MBixIPdk75+NoA==@kvack.org X-Gm-Message-State: AOJu0Yy7Kj2jlxynvXF22RWOrQbJLxQyHKUyBfUYqwfqQeRBrQI6xJDu 42HVg2G0Kd9ojLPDtBPrDYPqm4zUf5/ZzdrrsdpSO6yMlePTZx74 X-Gm-Gg: ASbGncvhCfwb68/dnzowUWqJ10oXTrd65n134TVtsLa+fXGYPdMN2V3mjVFMIuHHrsj MvCzitPEo9zSLH9n02QkoO2fALS1W6Efa6VIhClEANx4si7XoisNcrvkEgEhWi7eNkC0l175g3m AjQOwHct/UxWr2GH81oyWdZlQaon4drWaloZHns/90J1tIxaQWUaUVcA4noxGnUWZ2rucuV4j/M MEG2l3xCGTsrc3kd1nZqYsG3EMEYZi68kx7bcYS8X+HPpOwa67jXnYhDanyXmHJCYJUJiHl9Hzr 79H6bhY1sgw3HZpS2sw4+GCuMGe7cFA4yH9PLY6DPsaxrZHo4B/Rb0RQ9pDNvmlSQorpw2cP X-Google-Smtp-Source: AGHT+IFu8TvrOT7mfZlte7YEsHySoAvhmP73oO9Gk3cGuB1EeFBjmVGx38umUR/hSO0hUwEMZUynqw== X-Received: by 2002:a17:903:3202:b0:220:faa2:c917 with SMTP id d9443c01a7336-22c53611075mr3914835ad.34.1744920618125; Thu, 17 Apr 2025 13:10:18 -0700 (PDT) Received: from ?IPV6:2a03:83e0:1151:15:6f0c:5f5a:e370:874b? ([2620:10d:c090:500::5:a81]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22c50fdf1dbsm3988915ad.258.2025.04.17.13.10.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Apr 2025 13:10:17 -0700 (PDT) Message-ID: Date: Thu, 17 Apr 2025 13:10:16 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 4/5] cgroup: use separate rstat trees for each subsystem From: JP Kobryn To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: tj@kernel.org, shakeel.butt@linux.dev, yosryahmed@google.com, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-mm@kvack.org, cgroups@vger.kernel.org, kernel-team@meta.com References: <20250404011050.121777-1-inwardvessel@gmail.com> <20250404011050.121777-5-inwardvessel@gmail.com> <2llytbsvkathgttzutwmrm2zwajls74p4eixxx3jyncawe5jfe@og3vps4y2tnc> <88f07e01-ef0e-4e7d-933a-906c308f6ab4@gmail.com> <337ce68f-5309-4bb2-83ae-cb43268f447d@gmail.com> Content-Language: en-US In-Reply-To: <337ce68f-5309-4bb2-83ae-cb43268f447d@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Stat-Signature: njh8nypujf45pqkswiau5hfp1exhwmfq X-Rspamd-Queue-Id: 8599780003 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1744920619-468709 X-HE-Meta: U2FsdGVkX1+dInjbV1WoPmws21rUK8OulljbBMOLU5dw06et7WnT6wO8YMnsiWlP163NFlHxZzDZ/C1qUO/SKf6ng5VL6kG5aqBsJ33QlxOiLJqxYGFsl5GlVvORyf4W9XthW01CkYiZC0u9NlcCEH1ePDP/icIAVvk9I6nLFn1A92ujDRX3AUnIz9uXAYEhkEn2GeRCPdfYmSVmL3uR1NOn28F+kkG/YaPZQ/+RzXk8HoFxnph5vn9aumeRj2A9HQ8TkKJWSpsYo60+v0/zN1X5Je0i7FfCpJI6CQ98W0LpJvKMDsEG/LDFtOkwGEn0VhDUtrs9aAGUt2//nxDE9M4Ad/NvJ61XHRnyWPIjAGgrI7GSRwz+KJlFjYc6JIpQ8H77GLfm5h9fogG5MbQqgX45In90BUnnwCckb1JCXpNsH+/5U+gy3XrPSl+8pe3jdEEVXdq4cBUAjitpy9OBGAqQkwQqEJHhSWWPwfJoruq5T13kGaXScbBxqz9Ch1nkgTnJp/5GwLu4JJr0rq6G6Lk3UEPzP6gzEKRPLY7FE3IoNdILEiPFktKJUUVquZFjyt7tWGUj1WUDfxe5BRKifL4bQemf20A4YKc1mTy1iGTRhM0ttbkUBoHE3pBmKKqj7c/uavmpUd2jVSmNFj1y1C2oe17Kt507MiVo44EBOnAgQyiDoM1ORcSZFVITqWiYhc25d2WUV5c07OZ+Ey/x9FdGML88y8p8rJU1boI1ndpCv3AXD/qDJTIBmKfkYVgYBO5Mjr/gFTo69AVbC741jIX1yGFvopr5u/PJ4+SthqUrGlKmVugtYU83zPNnyVu+KTXqqUxz3tSUVAZyh1eIxBdgTQH7Mwd4eTHgAGTD0gvj6nv6L4G0sYZCVS3GfLDVzTmnDLQwIhFdTIn8zBF1qjT9XXGqTchfferTbVLkbDU68HBXX8e+S+mi7ln5X9VJgVL3DSCr1E3zAWtkVjt F2VOL/w8 RNyl7pvqCNE3vDMlkPVNMlu82t5LL5p6EGmEE4+yCYPCm3+ic1HCzoai9/LfNegZL7uI/uhtm6Q2ERewG6SkDtE/7aU7vGmpX67U1cCqzJvrg78UPRt7zwlvMq0832wqVjcr0Yf/9yZs09HxpewOD5LKHfXjuI9KoFWnLAn+GqV9joRcZxCfVPkYnu+2o6yjaKubxlvpWi0TuliEsX0Vn9pG4lf7/9wBdQ73ITUg7fStfgNrctstgdNMu1HFvN8MdLVNb2zEeWURphkZnHW7GE92MzIbFQVrGRFHmOmdynHi70tIs09sQPIkXn3s5B5CSqDyVnqE8+2s1k7G6mautPM+wo5zsEQ+gCkrdGOSSc4nle0gEJrOErR9MzfcoRJ61JLT0P3iGF/qVSGzvTYizU0lCJc0OV94EcS9D1MfXivp1OccGVQK6u6pUE3oip81ZalTh/S6gqQKP9pw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.001691, 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 4/17/25 12:05 PM, JP Kobryn wrote: > On 4/17/25 2:26 AM, Michal Koutný wrote: >> On Wed, Apr 16, 2025 at 02:43:57PM -0700, JP Kobryn >> wrote: >>> Hmmm I checked my initial assumptions. I'm still finding that css's from >>> any subsystem regardless of rstat usage can reach this call to exit. >>> Without the guard there will be undefined behavior. >> >> At which place is the UB? (I saw that all funnels to css_rstat_flush() >> that does the check but I may have overlooked something in the diffs.) > > It would occur on access to the per-cpu rstat pointer during the tree > building in the sequence below. > > css_rstat_exit(css) >     css_rstat_flush(css) >         css_rstat_updated_list(css, cpu) >             rstatc = css_rstat_cpu(css, cpu) >                 per_cpu_ptr(css->rstat_cpu, cpu) > > Since I'm doing the early checks in css_rstat_flush() in the next rev > though, I was thinking of this: > > void css_rstat_flush(css) > { >     bool is_cgroup = css_is_cgroup(css); > >     if (!is_cgroup && !css->ss->css_rstat_flush) >         return; > >     ... > >     for (...) { >         if (is_cgroup) >             /* flush base stats and bpf */ >         else >             /* flush via css_rstat_flush */ >     } > } > > Then we could remove the two conditional guards in css_release_work_fn() > and css_free_rwork_fn(). Thoughts? Correction: just the one in css_release_work_fn(). In the case of css_free_rwork_fn(), there is a call to css_rstat_exit() which would still need to be guarded (or it will touch the per-cpu rstat pointer). > > Note that I was also thinking of doing the same early check in > css_rstat_updated() since it is exposed as a kfunc and someone could > pass in a non-rstat css other than cgroup::self.