Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3477374ybl; Tue, 21 Jan 2020 01:17:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyY1E09MPKCcM4fzrX4Di5Fl8oAI9jgOELzPwKdFo3h3anwNOAQerHXrtCaBLAW3cqUBJi9 X-Received: by 2002:a05:6808:53:: with SMTP id v19mr2118028oic.169.1579598268411; Tue, 21 Jan 2020 01:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579598268; cv=none; d=google.com; s=arc-20160816; b=ZD6iyrI/rjCbtfWQ1vl1uV1TIwjUKtQda9oR3cemmQoKVzMrd/v/Y/kwo9y0q0c4Y5 ntNJIVHUUjwNpOs5G1qZ8Q2MswPRQ0ZuJT4qDhZXnancmEsmxVeqs6rrYdn/yszom0tO sLbf25DB1VryUItfEeoCE315+dkfs8/tB6D53JmVrezlvA3WfwxCH9rcI5nm5QQqJNSv +bC+WLUVyc5URbmj4OSPqTsUteXKmQ4toIavwbuVkAR0jOVrbREsquCHP9iHDUFzplGW lK8DZr6WxwtJiYkE/S9pgjpf4SCFYyI4GALnEQsaQwfj5wFN+QvIK8ye2XF1d8lzaPKN 9l1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ANXkNq5QvqcOwrIgPpsFYa4JWlL8ZcM65Bre6rHpQbs=; b=wiQUpJx0Gzdl5zK500KYFkqm1kNV2YfjQCpEwdCaphRYNf6snOhyt29+MnQARLVRDx 9h9yH+W9bLhrxqjy2OE9K/fiwyKoDRmLAPbth8w3l5G2We9iVCOWnYk1haJ34/+I/g6r /Yva4B/Rj4ET5/UlY4n3u9V+Le8pnJUJ8q4Gr8fWAeuDcYxmP2ZurCjd2Fj4AUhviOFs CkQi1NagT3jDBBQuU+PcHWyMyrpo5rRCNPUcp5FYUa4b4sup8HwxOnVJbgsWONynKfRS PoxQU8Nll6P96cm7mH/wYymSjABWLXfZsmCf6yHM5/Ii3a0MrHTIjrklaOqXu1V/S37l S1FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=J64FB2M6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si19125641oia.236.2020.01.21.01.17.36; Tue, 21 Jan 2020 01:17:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=J64FB2M6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729016AbgAUJQk (ORCPT + 99 others); Tue, 21 Jan 2020 04:16:40 -0500 Received: from mail.skyhub.de ([5.9.137.197]:36260 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbgAUJQk (ORCPT ); Tue, 21 Jan 2020 04:16:40 -0500 Received: from zn.tnic (p200300EC2F0B0400A009400066D53C66.dip0.t-ipconnect.de [IPv6:2003:ec:2f0b:400:a009:4000:66d5:3c66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 35D291EC0B7A; Tue, 21 Jan 2020 10:16:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1579598199; 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:in-reply-to:in-reply-to: references:references; bh=ANXkNq5QvqcOwrIgPpsFYa4JWlL8ZcM65Bre6rHpQbs=; b=J64FB2M6EXfWriRaoAsTY1CSeMYYgdPGWM+OZUYjcNmFBa81Rcrx0MyBQafpYQzunZV8Kl 5pXsYdJcL2VCJjYhHsEQRTW/IQkOFnMYdo+Nh/qSHUL0EQkmueKW0TCxX78uw82UE+GS0y A5PzeCM2IDJ3O9spe8T/6TvqEUUNBK4= Date: Tue, 21 Jan 2020 10:16:33 +0100 From: Borislav Petkov To: Marco Elver Cc: Qian Cai , Thomas Gleixner , Ingo Molnar , Dave Hansen , Andy Lutomirski , Peter Zijlstra , the arch/x86 maintainers , LKML Subject: Re: [PATCH -next] x86/mm/pat: fix a data race in cpa_inc_4k_install Message-ID: <20200121091633.GF7808@zn.tnic> References: <20200121041200.2260-1-cai@lca.pw> <20200121072744.GA7808@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 21, 2020 at 09:19:18AM +0100, Marco Elver wrote: > As I said in my email that you also copied to the message, this is > just a stats counter. For the general case, I think we reached > consensus that such accesses should intentionally remain data races: > https://lore.kernel.org/linux-fsdevel/CAHk-=wg5CkOEF8DTez1Qu0XTEFw_oHhxN98bDnFqbY7HL5AB2g@mail.gmail.com/T/#u Yap, I agree with Linus on the legibility aspect. > Either you can use the data_race() macro, making this > 'data_race(cpa_4k_install++)' -- this effectively documents the > intentional data race -- > > or just blacklist the entire file by putting > KCSAN_SANITIZE_set_memory.o := n > into the Makefile. > > [ Note that there are 2 more ways to blacklist: > - __no_kcsan function attribute, for blacklisting entire functions. > - KCSAN_SANITIZE :=n in the Makefile, blacklisting all compilation > units in the Makefile. ] Do we have all those official methods how to make KCSAN happy, documented somewhere? > I leave it to you what makes more sense. I don't know if there are > other data races lurking here, since cpa_4k_install is not the only > stats counter. In this particular case and if it were me, I'd prefer the __no_kcsan function attribute because it is kept outside of the function body. But I can't find __no_kcsan in current tip: $ git grep __no_kcsan .h:204:static __no_kcsan_or_inline bool constant_test_bit(long nr, const volatile unsigned long *addr) include/linux/compiler.h:215:# define __no_kcsan_or_inline __no_sanitize_thread notrace __maybe_unused include/linux/compiler.h:216:# define __no_sanitize_or_inline __no_kcsan_or_inline include/linux/compiler.h:218:# define __no_kcsan_or_inline __always_inline include/linux/compiler.h:225:static __no_kcsan_or_inline include/linux/compiler.h:238:static __no_kcsan_or_inline just this "glued together" thing __no_kcsan_or_inline. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette