Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1933662ybv; Thu, 6 Feb 2020 12:33:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxKzia4IX4CKRe06AuoTFbiTl0KOvHjVhAzasFQVJspSubVrAsUskOqItGCY7RlEdcn7kEE X-Received: by 2002:aca:ccce:: with SMTP id c197mr8016563oig.31.1581021215876; Thu, 06 Feb 2020 12:33:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581021215; cv=none; d=google.com; s=arc-20160816; b=H17cUd3kR4WFoo+kFnZfXjB3KmXSrSbb0LACna3OuqVBIhm/JY9RVq65O7VCCWvVpI M1p314LlDbIRscnJDKHNlxJmv1gUQkuvlxJIHHMgzPQH6oqXpvC+Mpc63zSg2e0QnRVn bs9F2VxKkS6uoVcoaII5PhNBHdNjrBtfg6t8cEs40zD63W/l2UFPZlkAH1++PMHKbMZ2 IAMlVChlf3xGLsWMN0yivfulAX2ywr/fHbz3risBYKBvDQYVbLUZQJSfS33xhXmFwrF9 Mi7HNbp8jFfC4uRZmnB6BJ/DtRliCnUmbISdhH+QnJbiHA6+vmMLOD4Fdi6bjJCWoBCb kkMg== 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=gJbewMsHDVUVh+mQTq3o5gvQ9Bp13UC+F2iCFMLgKQo=; b=nj9g4LL53wWXHZfwzUnufw69BOjnLShpXKJuYE7kDzXUJvbtkA3yt+so903qgGnS2F j28nUzSfBTpHrIlw2U8AoC90+gBI+9nsvO5iu6ly9n3hlMhVJqbVw5nECv49Ttv2OOEB gdkEkg9bQRiymnsOP3Vpncfprd4Vj3v0tSNp+53mkWBV60qA1yp03JZSOknCxWhy66QH 0yfhqNuULdoEcH8Go5ygEyZ/Hto9CkUmEBiGNV77ESpQh3lk0qriwAtjXz6LS/OmLtBM XIj/LppNWJ9AzKIkyMFiFPHjGoTT5PEeR+LuCnkObT0Zs56Hg1+vH0wiG95BcnKMi58z 20kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=nf8aNdh3; 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 s15si2736615oih.252.2020.02.06.12.33.23; Thu, 06 Feb 2020 12:33:35 -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=nf8aNdh3; 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 S1727932AbgBFUb4 (ORCPT + 99 others); Thu, 6 Feb 2020 15:31:56 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:36769 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727698AbgBFUb4 (ORCPT ); Thu, 6 Feb 2020 15:31:56 -0500 Received: by mail-qt1-f193.google.com with SMTP id t13so152267qto.3 for ; Thu, 06 Feb 2020 12:31:55 -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=gJbewMsHDVUVh+mQTq3o5gvQ9Bp13UC+F2iCFMLgKQo=; b=nf8aNdh3/8vP+W6SEn5KZenp8fTVGziOmZartWyRum8Wqy1f9ey00xYjpPQClOVE3D 68kcBncv4V9Q7NCw3t96JYeVPzbunNmBb/9HKY9p615QIe/64MnR9PZGyr1JN3I0u4pK ed6yePVHQtBooopmWBhtYlKj6PJZQY1poubQ1HciuI1R57AxRi32xTAeTm73WktqQxHA 9d+0w6w8jDBrCCzbiCi8prOR8l1oZgJqHz0w4KIClxWaLQqa1rEO4MbOjcKhbZf3QbLc RMR7jzSbb/TF9cA3UFIDTW0cea5UWVT6Hl9M61KcNe8gut9qC8t7GJnmFVqAfdm1pbFb 7UGg== 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=gJbewMsHDVUVh+mQTq3o5gvQ9Bp13UC+F2iCFMLgKQo=; b=DO5IztjVQG3Kajvf3P9VbY1XS1pbJNDbBxuZS8V0wjsKTIDfkXZEIWsJcElCZmo+xF rfCYokpxzt95U3GtSgKX/OMXHkji3B+hJHFJTifPxvK5IfOmihFmeogTLm0MaW5g7+N6 hWb2Amo0+z+2PiQy33aRelZwXdVNlvk5BXMVEpM3Dd1nMeCsQoS/3n44Boa+Zllry5VX 6EMFOlgfw47SkCJySnEO8dluyBz+UC/qllLUUT3cnwBOo78eXjX1weVnXjd4NTingE7R g1ajGFbye0ZkHTbOOWUjFLtO0jfxzF8UcTy+7QN8IJPP8bAhKkWT1mrRQNYrQ09T59Bz gJDg== X-Gm-Message-State: APjAAAVifOGqGxSqFPFb4FGKpeJqCqOBEcoE4FOGG6UX+bJpGVj23B71 YKO1N67+P1ljPQru0VbQChgqZ489rphSgw== X-Received: by 2002:ac8:3a02:: with SMTP id w2mr4186584qte.351.1581021115295; Thu, 06 Feb 2020 12:31:55 -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 b17sm212383qtr.36.2020.02.06.12.31.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Feb 2020 12:31:54 -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 -next] mm/page_io: mark an intentional data race From: Qian Cai In-Reply-To: <20200206035654.2647-1-cai@lca.pw> Date: Thu, 6 Feb 2020 15:31:54 -0500 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <5B9299F8-C495-4675-B8F5-BAEA28D45586@lca.pw> References: <20200206035654.2647-1-cai@lca.pw> To: Andrew Morton 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 Please disregard this patch. I found more data races in this file, so = will send a new patch to have them at once. > On Feb 5, 2020, at 10:56 PM, Qian Cai wrote: >=20 > struct swap_info_struct si.flags could be accessed concurrently as > noticed by KCSAN, >=20 > BUG: KCSAN: data-race in scan_swap_map_slots / swap_readpage >=20 > write to 0xffff9c77b80ac400 of 8 bytes by task 91325 on cpu 16: > scan_swap_map_slots+0x6fe/0xb50 > scan_swap_map_slots at mm/swapfile.c:887 > get_swap_pages+0x39d/0x5c0 > get_swap_page+0x377/0x524 > add_to_swap+0xe4/0x1c0 > shrink_page_list+0x1740/0x2820 > shrink_inactive_list+0x316/0x8b0 > shrink_lruvec+0x8dc/0x1380 > shrink_node+0x317/0xd80 > do_try_to_free_pages+0x1f7/0xa10 > try_to_free_pages+0x26c/0x5e0 > __alloc_pages_slowpath+0x458/0x1290 > __alloc_pages_nodemask+0x3bb/0x450 > alloc_pages_vma+0x8a/0x2c0 > do_anonymous_page+0x170/0x700 > __handle_mm_fault+0xc9f/0xd00 > handle_mm_fault+0xfc/0x2f0 > do_page_fault+0x263/0x6f9 > page_fault+0x34/0x40 >=20 > read to 0xffff9c77b80ac400 of 8 bytes by task 5422 on cpu 7: > swap_readpage+0x204/0x6a0 > swap_readpage at mm/page_io.c:380 > read_swap_cache_async+0xa2/0xb0 > swapin_readahead+0x6a0/0x890 > do_swap_page+0x465/0xeb0 > __handle_mm_fault+0xc7a/0xd00 > handle_mm_fault+0xfc/0x2f0 > do_page_fault+0x263/0x6f9 > page_fault+0x34/0x40 >=20 > Reported by Kernel Concurrency Sanitizer on: > CPU: 7 PID: 5422 Comm: gmain Tainted: G W O L = 5.5.0-next-20200204+ #6 > Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 = 07/10/2019 >=20 > The write is under &si->lock, but the read is done as lockless. Since > the read only check for a specific bit in the flag, it is harmless = even > if load tearing happens. Thus, just mark it as an intentional data = race > using the data_race() macro. >=20 > Signed-off-by: Qian Cai > --- > mm/page_io.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/mm/page_io.c b/mm/page_io.c > index 76965be1d40e..e33925b9178c 100644 > --- a/mm/page_io.c > +++ b/mm/page_io.c > @@ -377,7 +377,7 @@ int swap_readpage(struct page *page, bool = synchronous) > goto out; > } >=20 > - if (sis->flags & SWP_FS) { > + if (data_race(sis->flags & SWP_FS)) { > struct file *swap_file =3D sis->swap_file; > struct address_space *mapping =3D swap_file->f_mapping; >=20 > --=20 > 2.21.0 (Apple Git-122.2) >=20