Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1098886ybv; Fri, 7 Feb 2020 14:29:36 -0800 (PST) X-Google-Smtp-Source: APXvYqx725G2bM6Tolcc/HM+dJWQ3Q9stwERCKs882LKQhC78zkB/QbDTyvBFyr6QlCEXvGWDsAN X-Received: by 2002:aca:fd94:: with SMTP id b142mr3500714oii.11.1581114576837; Fri, 07 Feb 2020 14:29:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581114576; cv=none; d=google.com; s=arc-20160816; b=szXIQHg5UuwDw3WnYO0ook7AP2pi7cxnxb+1hBPG6RmkbQjPAJnL773C8WcPqOUT/8 aBVjxfeYTcMh/1HMkxJ58VPnNtIST34x2FGChDCpkEGRK2Seb3RIiXNdjONyR/hlx1Me 9O1R7LAwNSNGITPN1bPC1rkUG0d9g7+RIfBV0pAihXjRCyUq11EvAcrBu02yRudzvoI3 2kGv1XvHNmJwA82AjiRlQTlkyysUJ2Y7WQeLal2tkeL0xH9jgY9vJWe02mJK75uk03Qd 5L2CowmDWSdo/7l0ktbNTcTyw2d7fiF/aaXelDitT7Oe3BFvYEoqq80RxDbWO0fqsKtC m1pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=OxQxNArYNGHpxlZi9BnAGnVmegvkSAJw3+w836VhUe8=; b=aoHUE0SCBy6LMujhEo8/FeZ+jf/US9BmezRFdOuHKISkeaXn6iiJZUQ22coiV9LbnQ 98s3tJbvAnXaDdOM0SaakzWZgPunqods2lM/UJ4N32wT4OeaWwlQQ3Mt7G6KNVxpUqoM tS8pMlNZS6JLIdl6fH9icy2xw8wv78WwCSfy3zbX/ftc47lQs5X+VVgR6cwfGdDfO5ZJ FbP6Dn2SNseYH81Dbv+IQ7nqGUyBEc5LOXv/yIlhkztwx0ixSWQTIhX8FJSWlvuk0/TT hgwQuwQ+fP9yQduceaZugrYo99udaOoS63kvdBPGXpZCmhME0HoJu/6PVUBG/l1zAcwE +urQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=ASbWDq92; 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 a6si4199272oia.33.2020.02.07.14.29.23; Fri, 07 Feb 2020 14:29:36 -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=ASbWDq92; 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 S1727075AbgBGW2b (ORCPT + 99 others); Fri, 7 Feb 2020 17:28:31 -0500 Received: from mail-qv1-f65.google.com ([209.85.219.65]:39030 "EHLO mail-qv1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbgBGW2b (ORCPT ); Fri, 7 Feb 2020 17:28:31 -0500 Received: by mail-qv1-f65.google.com with SMTP id y8so379159qvk.6 for ; Fri, 07 Feb 2020 14:28:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id; bh=OxQxNArYNGHpxlZi9BnAGnVmegvkSAJw3+w836VhUe8=; b=ASbWDq926fcNVDgknBiKGTLT42W+QI+Bhd1PCULk+mNsfdo/lBFhXkzzGUSgFBul0l SCk7Z1XE0kp7iIqvq795oi6i3XbnxbpY+uRL2kzWMbIR4DPBPDlMG++8MUH1ooCcgQfe rNx4yhIqbwaFJXgFai46dnd8JV2YiiATTWKKlA7vKNxLFGoR51A915fQq9pnuOKWXqEn L+yS+4Q9SbJ17a+8SUGmObjkiz0y8WXEgkjjlUy2Cacz1TjVghdMXCrZU76qUuxy/0fs NKPR6WBxfQlHBEw0VdinYwK474DegWIzNzjRY5vrXSCZ8uVkk3RcwOBywjrvcJyQy6q+ 1mfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OxQxNArYNGHpxlZi9BnAGnVmegvkSAJw3+w836VhUe8=; b=sKv2v5i4UgxNgJfZCA4FK8GyJWFCoEhbia+ic7av4cYP1oqrRcgXh5OF7Vd+Z6+03x CyCRirvU9EMmJSuYsmNpiaKtIyDdQtMa1So7enX8MApc9WoE921xs2t+YdAMjAYaZ1kF B0VZ21n6Ta1xGDLhXu9Ex0UmxDZNfs4c0ZDGboOkfe77sSCdBC8NUtI6/peCsM4Dcni5 VIiuy0hEKw1EmQugPxkb3Kwe3TsAA9wHyY1XNq1AumvgvcqYigIX1RXwhj/wjFKv517S o/U3GdFXcJltyakEDFvRR9iDrgD62DHHmiO+kJIW2s31y56qSE3ZhE6P2/jOkv6IO94o 3t9Q== X-Gm-Message-State: APjAAAWjL7o9d0f8kkgRpj6JcQhqZneR+Gpy2uiV/rMMKJ5qqxCExumm JI1DXAGDHflE/BL+f58RvQlK2g== X-Received: by 2002:ad4:50d2:: with SMTP id e18mr581284qvq.9.1581114509926; Fri, 07 Feb 2020 14:28:29 -0800 (PST) Received: from qcai.nay.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id j206sm2001762qke.54.2020.02.07.14.28.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Feb 2020 14:28:29 -0800 (PST) From: Qian Cai To: akpm@linux-foundation.org Cc: konrad.wilk@oracle.com, elver@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH -next] mm/frontswap: mark various intentional data races Date: Fri, 7 Feb 2020 17:28:19 -0500 Message-Id: <1581114499-5042-1-git-send-email-cai@lca.pw> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are a few information counters that are intentionally not protected against increment races, so just annotate them using the data_race() macro. BUG: KCSAN: data-race in __frontswap_store / __frontswap_store write to 0xffffffff8b7174d8 of 8 bytes by task 6396 on cpu 103: __frontswap_store+0x2d0/0x344 inc_frontswap_failed_stores at mm/frontswap.c:70 (inlined by) __frontswap_store at mm/frontswap.c:280 swap_writepage+0x83/0xf0 pageout+0x33e/0xae0 shrink_page_list+0x1f57/0x2870 shrink_inactive_list+0x316/0x880 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 read to 0xffffffff8b7174d8 of 8 bytes by task 6405 on cpu 47: __frontswap_store+0x2b9/0x344 inc_frontswap_failed_stores at mm/frontswap.c:70 (inlined by) __frontswap_store at mm/frontswap.c:280 swap_writepage+0x83/0xf0 pageout+0x33e/0xae0 shrink_page_list+0x1f57/0x2870 shrink_inactive_list+0x316/0x880 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 Signed-off-by: Qian Cai --- mm/frontswap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/frontswap.c b/mm/frontswap.c index 60bb20e8a951..b8c14f298332 100644 --- a/mm/frontswap.c +++ b/mm/frontswap.c @@ -61,16 +61,16 @@ static u64 frontswap_invalidates; static inline void inc_frontswap_loads(void) { - frontswap_loads++; + data_race(frontswap_loads++); } static inline void inc_frontswap_succ_stores(void) { - frontswap_succ_stores++; + data_race(frontswap_succ_stores++); } static inline void inc_frontswap_failed_stores(void) { - frontswap_failed_stores++; + data_race(frontswap_failed_stores++); } static inline void inc_frontswap_invalidates(void) { - frontswap_invalidates++; + data_race(frontswap_invalidates++); } #else static inline void inc_frontswap_loads(void) { } -- 1.8.3.1