Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3291906ybv; Sun, 9 Feb 2020 20:06:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyur6eLsXxXD22HVPhw/cHdXKd4EZ7KOqRrAwHsqIpW7KmG8+UEGQcvRnEgqn5QvOtvui6T X-Received: by 2002:aca:3542:: with SMTP id c63mr9505216oia.135.1581307604217; Sun, 09 Feb 2020 20:06:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581307604; cv=none; d=google.com; s=arc-20160816; b=wOyI5il7wQpcluwoHmwKtD/FoCKmLOS2FsXHTd7LpoUgO3c5iMkscSsXbRsCxOFRjj UBNO7MyUQSGc/OwZ6YALWNck+wM9p9Gc2otQl8yXyjfQBztPi9Q92x0b65xayUmORZCb QXrKw4lrmW5c+yUEuAVlPh9Zq6O5L0jfveLF9MB705jhREthFNHK5LxDpZP3RLWIYatC whnc0FmOPwCIAuTKdvQyKp7pGScx0OkMoQ3E2uppWfFrl/lL+h/bnOGiUeaN0rQsNKhT ovwcy5GPHocg3I9dTUduC/w1Vf5hWNRAVXSi8uEeM5j4z3zIo29y2gOWgxdJs5ob2Vz7 KUTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=byulLc9mHbRnuv6nXJYGcRH01i0XCQto7Iam78ERIjQ=; b=mlpZojYYw0JK9LzDNXWLq1dn3djE7fGC+hMkNNf38251bXM2YAdfmsXnOKOUdBWBzG l7+lRBEQTn7doU66+bfv9dznp8MAeg32AwghiVT66u/wUgOLpcInxwN9LegNmS3Rz5B4 W3GOwxnGrZWRLJXrPZ8if+HLCB8BCjklHcWe4aapJpB9Qpwekd749tZjO/NEg6V/l/uP SX5OianUGikVSWVdwTo6O3IG/2NG7FBQT28jEbLYFVrHroMG8ikWZmHxyg4gfxQx1fPW kRj0KWgYuabh8svIzc36ppcWzGc44EkP9MnFxTzCL/atNPrsveS14vS9ALKmdr+l4wbg jeHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="roX/OaMP"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t28si3959033otr.16.2020.02.09.20.06.31; Sun, 09 Feb 2020 20:06:44 -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=@kernel.org header.s=default header.b="roX/OaMP"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727045AbgBJEGW (ORCPT + 99 others); Sun, 9 Feb 2020 23:06:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:38246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbgBJEGW (ORCPT ); Sun, 9 Feb 2020 23:06:22 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 131AA20870; Mon, 10 Feb 2020 04:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581307581; bh=mgQgZnHgJLUe03AmTrnxQLHDg/eEeWeFgD4hyyYyxP4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=roX/OaMPuaOv9ISVlRhS8nrMi9iND/OqFcBkES9ueWrlcDx64VzCadTQKwBbre8iM hwBbMd4Qi1C6yYmyiossT24qhGZlW6MjKtT647usK5EpaYia6+geLFpXS1Awr1tvUE +eUX7COsz5JFthVysynN0wpwQhohR5qSKA8lksP8= Date: Sun, 9 Feb 2020 20:06:20 -0800 From: Andrew Morton To: Qian Cai Cc: Matthew Wilcox , Marco Elver , jhubbard@nvidia.com, ira.weiny@intel.com, dan.j.williams@intel.com, jack@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next v2] mm: mark an intentional data race in page_zonenum Message-Id: <20200209200620.883ad431b01bcd38939ff5b4@linux-foundation.org> In-Reply-To: <2B333FA6-AB17-4169-B9EE-9355FF9C42A4@lca.pw> References: <20200209182008.008c06f1cf4347a95f9de0a5@linux-foundation.org> <2B333FA6-AB17-4169-B9EE-9355FF9C42A4@lca.pw> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 9 Feb 2020 21:41:56 -0500 Qian Cai wrote: > > > > On Feb 9, 2020, at 9:20 PM, Andrew Morton wrote: > > > > Using data_race() here seems misleading - there is no race, but we're > > using data_race() to suppress a false positive warning from KCSAN, yes? > > It is a data race in the sense of compilers, i.e., KCSAN is a compiler instrumentation, so here the load and store are both in word-size, but code here is only interested in 3 bits which are never changed. Thus, it is a harmless data race. > > Marco also mentioned, > > “Various options were considered, and based on feedback from Linus, > decided 'data_race(..)' is the best option:” > > lore.kernel.org/linux-fsdevel/CAHk-=wg5CkOEF8DTez1Qu0XTEFw_oHhxN98bDnFqbY7HL5AB2g@mail.gmail.com/ > > Paul also said, > > ”People will get used to the name more quickly than they will get used > to typing the extra seven characters. Here is the current comment header: > > /* > * data_race(): macro to document that accesses in an expression may conflict with > * other concurrent accesses resulting in data races, but the resulting > * behaviour is deemed safe regardless. > * > * This macro *does not* affect normal code generation, but is a hint to tooling > * that data races here should be ignored. > */ > > I will be converting this to docbook form. > > In addition, in the KCSAN documentation: > > * KCSAN understands the ``data_race(expr)`` annotation, which tells KCSAN that > any data races due to accesses in ``expr`` should be ignored and resulting > behaviour when encountering a data race is deemed safe.” OK. But I believe page_zonenum() still deserves a comment explaining that there is no race and explaining why we're using data_race() anyway. Otherwise the use of data_race() is simply misleading.