Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2118527ybv; Thu, 6 Feb 2020 16:21:00 -0800 (PST) X-Google-Smtp-Source: APXvYqxQakK0Y5NOcZyMqgXY3gOH49lulmNb7ArQ1Z20tGiZmLVC7gXWTRZkxh6SEjD2oDdgLomp X-Received: by 2002:a54:410e:: with SMTP id l14mr315729oic.42.1581034860762; Thu, 06 Feb 2020 16:21:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581034860; cv=none; d=google.com; s=arc-20160816; b=e/Ys7lfkcjDXHCtNSbYxQcBvbgG8zSiQZAFYJndTCS/hNfp2oBxh+1XUdRD3CEr2m9 5lA58xdQ8EdJGKMateS185TcNFP69LYLEkao/oHHrX5Agi6tH70aMEDZmHdXXGcR/X7K o/FrQPVXGdCARr5PFHbnSBcWnJbi2kKU9CSNzSm9dJU+1y3MTYr1bq7k6YYyGi6dpvUX EpBiRgbIiikEbiSAkZsVRp3rSzofE8hdl0uUhBcklUsIZITbsj3Kk/lQqo2H0RnN55F8 NLFJyXkidbD820Rh1/SY+fqNJ0aHFWs+rGUiiPlnXfyr+hoOtwrGfzgR9IJGA44tAmg3 U6Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=m2dTuWO1ugKcCHTxp+o4yxt+su2yu8181wVA1BN+7GA=; b=cCg6LHaFLcqUnw3nnI3K7zv7a736Ckl6kIsy+XSm/DSxG30wqBp5vxoVoWd9HRR607 yPmm9rJN1xSrrcnUXmWLC4dVCKwEd/WDjbSyXXNjOvCv7X9IFPII9HJLUlqtYhxXgvT3 5UezhQJRImlgFVGp90cRCspR3GSoctpzCpd6bL9ClDaFKM5SoG9wqr9NxkY5qxIi8JvL qcQmY0d84AKLg4B7KIxwshXwoZ+vmFg+B/1rDzO/Bpsv0U42QZvJDHt5SyHHPLFgAdvZ M5onI/K+oDaMGDns6fxv3zC01X/KJjMW/6vnqETQPFMzyW5fPEDI4C4mMDF0V5MTP6P2 ig9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=B12iZ8ko; 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 m85si2958335oig.158.2020.02.06.16.20.48; Thu, 06 Feb 2020 16:21:00 -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=@lca.pw header.s=google header.b=B12iZ8ko; 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 S1727390AbgBGAST (ORCPT + 99 others); Thu, 6 Feb 2020 19:18:19 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:42665 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgBGASS (ORCPT ); Thu, 6 Feb 2020 19:18:18 -0500 Received: by mail-qk1-f193.google.com with SMTP id q15so528190qke.9 for ; Thu, 06 Feb 2020 16:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=m2dTuWO1ugKcCHTxp+o4yxt+su2yu8181wVA1BN+7GA=; b=B12iZ8ko/b6w6maPcjEcpsoonvUtE2A1DTzmX6pv+zpWPUgPquTz3qKUIBBmF2rkqI 8NDyiIztfImGvwbT8GB5BTlo8SZ7WmZmQsRKt8u+lHdVOUCbs10h9UQFxdAYgbp13ldP oEjP5b3/4xj9FlITI0Cxgkmm0lL3fzIMjStd4PYwoOsoOSHMG8kVhccmLD66df7IhLEy 7xRfb9t0lkch2Z+gjrtBUiaWPOI0EEdIlHVEGwXPawVv7/dVhrbznhwTfSjIKN36zcV2 B1c6kxaOiJnqlsQotvevCyD3Si/WEui6mAu1KIAGuomlWA6UDh2UtKg3YX/LWcsmFNTH CThQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=m2dTuWO1ugKcCHTxp+o4yxt+su2yu8181wVA1BN+7GA=; b=jWCttexvRjP5gPL6FYNXjJa2Q+rK53z03v/hv2G7su8avKQMq2PxvLuMsxbmJoKxwZ /CVAiN0im7acZpHogA0zW9jGd037PseIyGTXCXbaHeNZS+Ahxt+ZounEMHeXVCmBujuv Zr/K4HMGbjdRAg7OTadbkJwDD+rEirbjhQtWlxUXmyLy5V7bmIK9RgzWUHm8m6WqxCDq pHwsOSOag0Vj4bApo6sG+YR0ABEi8TWcQbnyBg/dnjn7jKboJl1UFZDiLmMvb4kwX5yP iILRsIYys/ko5T6Ad+RpOEZNKKz1aPQgrEoqO5yqdx3u2CvZiVAXe6oI2W7pQ0I/8r29 XLVA== X-Gm-Message-State: APjAAAXffYN0yqCVJRfJwvtgO5o76P4S7MVkczbp3rIslJwQ4qE2Ob4p wxsOQwcQBOr7I1WXYSIjEhzY7A== X-Received: by 2002:a37:8e44:: with SMTP id q65mr5066875qkd.70.1581034697891; Thu, 06 Feb 2020 16:18:17 -0800 (PST) Received: from [192.168.1.153] (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id y27sm539145qta.50.2020.02.06.16.18.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Feb 2020 16:18:17 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Subject: Re: [PATCH] mm: fix a data race in put_page() From: Qian Cai In-Reply-To: <079c4429-8a11-154d-cf5c-473d2698d18d@nvidia.com> Date: Thu, 6 Feb 2020 19:18:16 -0500 Cc: Jan Kara , David Hildenbrand , akpm@linux-foundation.org, ira.weiny@intel.com, dan.j.williams@intel.com, elver@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <235ACF21-35BE-4EDA-BA64-9553DA53BF12@lca.pw> References: <20200206145501.GD26114@quack2.suse.cz> <079c4429-8a11-154d-cf5c-473d2698d18d@nvidia.com> To: John Hubbard X-Mailer: Apple Mail (2.3608.60.0.2.5) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Feb 6, 2020, at 6:34 PM, John Hubbard wrote: >=20 > On 2/6/20 7:23 AM, Qian Cai wrote: >>=20 >>=20 >>> On Feb 6, 2020, at 9:55 AM, Jan Kara wrote: >>>=20 >>> I don't think the problem is real. The question is how to make KCSAN = happy >>> in a way that doesn't silence other possibly useful things it can = find and >>> also which makes it most obvious to the reader what's going on... = IMHO >>> using READ_ONCE() fulfills these targets nicely - it is free >>> performance-wise in this case, it silences the checker without = impacting >>> other races on page->flags, its kind of obvious we don't want the = load torn >>> in this case so it makes sense to the reader (although a comment may = be >>> nice). >>=20 >> Actually, use the data_race() macro there fulfilling the same purpose = too, i.e, silence the splat here but still keep searching for other = races. >>=20 >=20 > Yes, but both READ_ONCE() and data_race() would be saying untrue = things about this code, > and that somewhat offends my sense of perfection... :) >=20 > * READ_ONCE(): this field need not be restricted to being read only = once, so the > name is immediately wrong. We're using side effects of READ_ONCE(). >=20 > * data_race(): there is no race on the N bits worth of page zone = number data. There > is only a perceived race, due to tools that look at word-level = granularity. >=20 > I'd propose one or both of the following: >=20 > a) Hope that Marcus has an idea to enhance KCSAN so as to support this = model of > access, and/or A similar thing was brought up before, i.e., anything compared to zero = is immune to load-tearing issues, but it is rather difficult to implement it in the compiler, so = it was settled to use data_race(), = https://lore.kernel.org/lkml/CANpmjNN8J1oWtLPHTgCwbbtTuU_Js-8HD=3DcozW5cYk= m8h-GTBg@mail.gmail.com/#r >=20 > b) Add a new, better-named macro to indicate what's going on. Initial = bikeshed-able > candidates: >=20 > READ_RO_BITS() > READ_IMMUTABLE_BITS() > ...etc... >=20 Actually, Linus might hate those kinds of complication rather than a = simple data_race() macro, = https://lore.kernel.org/linux-fsdevel/CAHk-=3Dwg5CkOEF8DTez1Qu0XTEFw_oHhxN= 98bDnFqbY7HL5AB2g@mail.gmail.com/