Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2348866pxb; Mon, 20 Sep 2021 19:41:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQZqMdAr1XA7zxJW+KL39O/dt2lw4OHziEa67+CLthmUqk9C5/ZqKbvRevR/qtiqMQv2or X-Received: by 2002:a05:6638:224c:: with SMTP id m12mr18432835jas.39.1632192112862; Mon, 20 Sep 2021 19:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192112; cv=none; d=google.com; s=arc-20160816; b=RHrd5o4g6pUJBtchjwl+2jHCUA+vpGLiazeaSwbx1nqtGWsTqOO6u4bd40FPTtvCa+ uGeduaXG6UOmhmHCVpu1L8wsCPCG1yH2SBoMN17XtV90ClrSMgBmHFyOlM7luMMMp8rn x/oOmS0R+mRf0j3xh7gNR3B17u975DTUB1un32uJtaQMx9s7Sjp2H2l6kNGq0HH1RmU4 uVNzPET1/DgKQ/oHJV5VSjLZX0tyQpezBbQO47ZHW6s9AWtukB3rIIX2FA9Yaucz8sfW /UsMV2EKgKD9aVpcz4W1IsJ5s417q/TlqgiqJZ+mUKGdtTUNxxHT5AUGfINGeRglWMuP ciaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=yj+rn7X7blaGJxKz6YARrP61pm4Y5j/vfBu3FSYFlDA=; b=BJNdaFvfJW6kQuLYk7pxfkvAV5BszV1SKCyK1MhtFfTTdse7nhkbnGTB0v7sYRoKSh wbAlcon4QZGozwCe8TYqdCivwjgPapj0nsQeRgNSuoKO8wQ6y9rLjXxdai1j9hfYSQAS QPgMhLV9KiPP//x2r9J+pItqC92pfuOk0IfY9T5/A8AwbRT7SK3u3yqEQNkbpAS1pgqu 3X7wYsl06UUWHnX2vdoi113hOxdouTO+aqTcFVluYlUr9Ybr85gF48SR49om4VYPDiw/ sOoKFJhKhWE3i3bjbSQBd2drL5FSoptgeB+fT18U5dToSqiYxpXpEa0IvJprEliJJwwm UYMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=qlehDK0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si13857157ilm.108.2021.09.20.19.41.40; Mon, 20 Sep 2021 19:41:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=qlehDK0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377066AbhITSPJ (ORCPT + 99 others); Mon, 20 Sep 2021 14:15:09 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:38012 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347555AbhITSL1 (ORCPT ); Mon, 20 Sep 2021 14:11:27 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1108121E01; Mon, 20 Sep 2021 18:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1632161398; h=from:from:reply-to: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=yj+rn7X7blaGJxKz6YARrP61pm4Y5j/vfBu3FSYFlDA=; b=qlehDK0CFFKnSnsii0H5002strjfvg/tJ9yr9Tlkpkwdvxv9Np/26+7aQvfmjvZ/f9kgOX DplAYbk5REraP/V+Ok0WeqY/SG46eO8MnmcRCksvswS4NoPhRzQ0bLuC6WvsEgRoT8RfSe wtlBzJtUDVCcAZBBkbpzKVbVXDL4wMo= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E09E713AE9; Mon, 20 Sep 2021 18:09:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id vHXFNXXOSGHAcgAAMHmgww (envelope-from ); Mon, 20 Sep 2021 18:09:57 +0000 Date: Mon, 20 Sep 2021 20:09:56 +0200 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Hao Sun Cc: Linux Kernel Mailing List , cgroups@vger.kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com, tj@kernel.org Subject: Re: KCSAN: data-race in cgroup_rstat_flush_locked / cgroup_rstat_updated Message-ID: <20210920180956.GA15043@blackbody.suse.cz> References: <20210917164123.GA13346@blackbody.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 18, 2021 at 09:27:08AM +0800, Hao Sun wrote: > Would it be better to add a `data_race` macro to the corresponding > location so that the false report can be disabled? Something like this --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -35,7 +35,7 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu) * instead of NULL, we can tell whether @cgrp is on the list by * testing the next pointer for NULL. */ - if (cgroup_rstat_cpu(cgrp, cpu)->updated_next) + if (data_race(cgroup_rstat_cpu(cgrp, cpu)->updated_next)) return; raw_spin_lock_irqsave(cpu_lock, flags); ? Makes sense to me. Will you send a patch (if this resolves your KCSAN noise)? (IIUC, this becase more visible after commit aa48e47e3906 ("memcg: infrastructure to flush memcg stats") v5.15-rc1 but it was present since d8ef4b38cb69 ("Revert "cgroup: Add memory barriers to plug cgroup_rstat_updated() race window"") v5.7.) > See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/memory-model/Documentation/access-marking.txt#n58 > for more details. (Interesting, learning...) Thanks, Michal