From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85938C35247 for ; Thu, 6 Feb 2020 20:31:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 39663214AF for ; Thu, 6 Feb 2020 20:31:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="nf8aNdh3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39663214AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DC59F6B0007; Thu, 6 Feb 2020 15:31:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9C4E6B0008; Thu, 6 Feb 2020 15:31:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB1C66B000A; Thu, 6 Feb 2020 15:31:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id B46816B0007 for ; Thu, 6 Feb 2020 15:31:56 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 65A3E181AC9C6 for ; Thu, 6 Feb 2020 20:31:56 +0000 (UTC) X-FDA: 76460848632.26.fact28_10e1e22169933 X-HE-Tag: fact28_10e1e22169933 X-Filterd-Recvd-Size: 5482 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Thu, 6 Feb 2020 20:31:55 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id d18so114713qtj.10 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=ZG79nKBgr2aCkUzzphsixEwWiQ1r7JeC+oFioys436XhbTw+oWtxO6pxMTG5ppY8e2 QxjdbuqSUpwrcWRzlsvr+OFPBIaoC7zYFY715Wnd0kWkAj/w5zeusC2nIWO3rYrr4a9U YqbL69qTBc/4G+cf8jtJqMWpKwh9J/0q5ghcYWCD4dFPgXXG+6do/L4vondSx9yHwSfN wKwQi15/iYl1CyVHGqSgfphrdFO90O92g3PRqE/V1Z5UOH3STiRJuzriMVE9J8pgJJrO LAvmzR3HdlcvBQ2GMUWt+LIu6Xlh4DzJMylwYvQm4utaqkjof2Y5M0RD6ZIMEDR3QUtH ByrQ== X-Gm-Message-State: APjAAAUWhCGUZJoUB5aegpDmP7RytpQlS9Jjn1jdUJbzKHTYSfISZCMp uB7Fb6SiLz6SpCvUtbGKaUU2dQ== X-Google-Smtp-Source: APXvYqyccwwtBVliPd+rxU1o4Pu5PuwWdPD2lPNRCAf1/BcKZbWbmaymmFFGO6MORI/PRZKNMQEqEw== 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000022, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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