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.129.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 3E8DE3321DE for ; Fri, 21 Nov 2025 15:47:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763740074; cv=none; b=HSlwxEqRx/eh2AUeQEDVfi2PIEaYNByit+vpN4SAPGSfLRz1f6o+TN2fe9YoxwyUeYJhvZeeRXG1nVxDOlN73D9DqR+5UKWWn59sUC++723/tUHmOv9PKQtnuMoXEG8uv9lEj7wQIlPLx6JoiX3OtsHSswjNxoAcAsvb9Otap3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763740074; c=relaxed/simple; bh=1wEaqFGx2DAZ8HZKwv7x8vg2ak+ntgM8SK6KYb0tLL4=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=P6cIV/tIBd9ijKOm+xu6z+01tXUcWcVkV3Hx7HCWdtLy0gS82gpAKwQB/CITHprF3jwR124SDoZzLO57UgjxPngSod2+IquM1S1/ddnLoi3J+txTZ8q1qyQv8F+eYPo3LZOxMiHOoFQ3UJBjuiDFtKkLvQbOnHBZsSjMKg2jRQA= 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=BZtZrkbg; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=VdkMS+8/; arc=none smtp.client-ip=170.10.129.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="BZtZrkbg"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="VdkMS+8/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763740071; 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=Fa3qKwfnivOIPXFNgSUhQ9fpoABoHPo2Ebm876qZAu4=; b=BZtZrkbgX0FYxq77puZ0jmaGp81WVzYUfEynqyiogaVApvAl8fFecG/99nEpM6wwICqnKb qEtdrSuz3T6tZ2wov3+RAi30n9ErB5z6IGB83pxULvZznDAJgCqkpkIlzA+REDtkShDn9I aSVsrvZG5pzUn52H/KB9VOlrHiiVVH8= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-ZkHy7fNRPsifWjEgi0xopw-1; Fri, 21 Nov 2025 10:47:49 -0500 X-MC-Unique: ZkHy7fNRPsifWjEgi0xopw-1 X-Mimecast-MFC-AGG-ID: ZkHy7fNRPsifWjEgi0xopw_1763740069 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-880444afa2cso29415206d6.1 for ; Fri, 21 Nov 2025 07:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763740069; x=1764344869; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=Fa3qKwfnivOIPXFNgSUhQ9fpoABoHPo2Ebm876qZAu4=; b=VdkMS+8/y/K8qdtc7ElHLvXsVqAseAEkY/FCVDrxgCTXgWlxYB7NYwIkYm2xMTCeCT YEeUX+Z/w0IJatNmWRI1QSWUDpVppzPqqEsD3K+mAjVSvGjbj+vGxTCwMFGh/AVJUwV3 k1dRvwh0m0Ub4Zdni9q8Hhz7p4vNyuZKRsdzqOyJG1f5MDQqeqtFAFR7Qx13P9DJ/XJO jnnOgdOUFplDDj3+m8FQNXubB5m+wnjaHN6uxGclZPeWHQGovZVwmQbQOU0IXulo3HQZ xhlk6z/gmaIeIyVA1NPDSbhlOaupxRjqKJy/JnEBrT/bFtz/ZbTLfVwSbHX4A0HhtVQQ uvBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763740069; x=1764344869; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Fa3qKwfnivOIPXFNgSUhQ9fpoABoHPo2Ebm876qZAu4=; b=rjK5mfr3mqD+ZVQxk6xnCjFGt4xq15r8kY96CdI97WjmTJNrfQPjmp8GJoqaFmbYmN yHYEsKA+Upw/KfriG3cTq9mmWBI8kSikVeG2kVLEV5RcCEHtovFK1ix8PLlfIbqzYsdj 4LUWt5bRG4ZKL0LBOTCohXNV4Lr6jMIlqyeYJLJa2hLek5c1AkUgcQu/TgaqfwV04GAo 92bS17vg9NSLkcYS9k2rMxhSMQlFgeYBdr9HtwDggaTRuNZSVbtW0O2FW8CK2wjgLzyG 2EW1SH3RYOqjnJ2R2Lh5IF8gMClxQDb+MvIsrVg3rUw23Hw9EMugk7K7I/tEoFjq4VwX myEQ== X-Forwarded-Encrypted: i=1; AJvYcCXXvu25B2n0epCaJegKvsK2HH4QbgglaLs1nc4iNZWsAV7p29S6kwDuMnh8AhY+HQqO5SiLE6CWGQlQUdI=@vger.kernel.org X-Gm-Message-State: AOJu0YyoqoPPWyVWcSQsvMMRyspKZ0ERJ95CdkXTe27ZoTzffe6jrC0S wOWlstoiGCiyK6pIdIvvLpAqdghSINr5YjK1/qi+9Cx1h0PxVWjjCTMaoUlTjRbZbCkgb4r/YU2 2Ouz1BHMtuSW+8a13dhx/yXMR96m1nTzSYYjxugg4AmtreSAu5Sr3tsCFzfyU9iyaFw== X-Gm-Gg: ASbGncsrNLGUuRSm+zqvNRXkRdkpMHfaLlj33h1CVyMKbrav2hZMHmdopGLGPKtI19Y fhYNc+Z1byqWGxvWFT9DLwZw3F11l+OtrMbPD1Fd2XIxe2qFdq5gWcCh4xsrLTDDK9GIMg0Nxlz 2IhF8W6gh4jnYq3QBUEghEzX9+44Wgl32WqqHMfvQby8BCUT06BFcNaBiF32yWxSI9yReiJPa9d XWqrPT+iWlq4HYPl51mVS2Hn1YOHE3QdtcN5yFhfc5EOo7VePTfk786K+JjNlPzKc5i8cyN8+a0 EJF0By+uYKQrleAMivvFNP2bUqm/3DknxkMBSq43bo1H8qhq73//FQi1EloveZWhYu6WGDpK+Fp UO+jgdecPnndn4ChmVaW5Bpmz5ngmWbSKzTbMCTiQCeUxZIaI6kkwcgYe X-Received: by 2002:a05:6214:4a88:b0:880:4ed1:ce3b with SMTP id 6a1803df08f44-8847c4d28eamr41404936d6.12.1763740069323; Fri, 21 Nov 2025 07:47:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUm/tL/TnU/6Byd6uQQSTP7PVavDYfah8RaBnivWn0Bd07mUj/63wgq3viDLKR2+Z3mUP8nQ== X-Received: by 2002:a05:6214:4a88:b0:880:4ed1:ce3b with SMTP id 6a1803df08f44-8847c4d28eamr41404376d6.12.1763740068812; Fri, 21 Nov 2025 07:47:48 -0800 (PST) Received: from ?IPV6:2601:188:c102:b180:1f8b:71d0:77b1:1f6e? ([2601:188:c102:b180:1f8b:71d0:77b1:1f6e]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8846e59ec1dsm41997836d6.50.2025.11.21.07.47.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Nov 2025 07:47:48 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: <0bcbe776-de46-42eb-8d98-e4067052b1df@redhat.com> Date: Fri, 21 Nov 2025 10:47:47 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] cgroup: Add preemption protection to css_rstat_updated() To: Jiayuan Chen , Waiman Long , cgroups@vger.kernel.org Cc: tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, linux-kernel@vger.kernel.org References: <20251121040655.89584-1-jiayuan.chen@linux.dev> <6cd2dc59-e647-411f-ba3e-2a741487abb8@redhat.com> <305559b6e8249a31ccbe1fe77fd3a3c041872c4b@linux.dev> Content-Language: en-US In-Reply-To: <305559b6e8249a31ccbe1fe77fd3a3c041872c4b@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/21/25 1:21 AM, Jiayuan Chen wrote: > November 21, 2025 at 13:07, "Waiman Long" wrote: > > >> On 11/20/25 11:06 PM, Jiayuan Chen wrote: >> >>> BPF programs do not disable preemption, they only disable migration. >>> Therefore, when running the cgroup_hierarchical_stats selftest, a >>> warning [1] is generated. >>> >>> The css_rstat_updated() function is lockless and reentrant. However, >>> as Tejun pointed out [2], preemption-related considerations need to >>> be considered. Since css_rstat_updated() can be called from BPF where >>> preemption is not disabled by its framework and it has already been >>> exposed as a kfunc to BPF programs, introducing a new kfunc like bpf_xx >>> will break existing uses. Thus, we directly make css_rstat_updated() >>> preempt-safe here. >>> >> My understand of Tejun's comment is to add bpf_preempt_disable() and bpf_preempt_enable() calls around the css_rstat_updated() call in the bpf program defined in tools/testing/selftests/bpf/prog_tests/cgroup_hierarchical_stats.c instead of adding that in the css_rstat_updated() function itself. But I may be wrong. >> >> Cheers, Longman >> > If that's really the case, then I'd rather add a new wrapper kfunc for BPF > to replace css_rstat_updated(). Otherwise, whether it gets triggered would > depend entirely on users behavior. > > Right now, this WARNING is showing up in all BPF selftests. Although it's not > treated as an error that fails the tests,it's visible in the action runs: > https://github.com/kernel-patches/bpf/actions All the existing callers of css_rstat_updated() except the bpf selftest has preemption disabled. So it doesn't make sense to impose a cost (though small) on kernel code that are in production kernel in order to make a selftest pass with no change. Cheers, Longman >