Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2504035lqb; Tue, 28 May 2024 01:42:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAZNX8lcQU56YxPrmYlSQmbZeKxnQ5vvYl2p+TmFMZy6dNCv17T+WONT15mHjCPYZRSdKNcdQBgLXtTAN+4vTVP4qq7NdbyShKv8t/ug== X-Google-Smtp-Source: AGHT+IFlubJ17H1NDBf4HHS1Bn8IWchYynG8PSDn4KPLXDiDSeAI7usMBRK837ldufMab7FTxa38 X-Received: by 2002:a50:ab4e:0:b0:570:5bcc:f749 with SMTP id 4fb4d7f45d1cf-578519b3380mr10579858a12.29.1716885756425; Tue, 28 May 2024 01:42:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716885756; cv=pass; d=google.com; s=arc-20160816; b=aBGaT++UoTwZlzoKgHvBa/aVH9XuWVZjLiGtXe8elkisGCk3fLoFvtOQNzQIEcmTiX MV+B/fx7k1fIFsMJcMx4hydnzxqpX4k8+NFqQCAr5wYjQsx5+n7AmjMf7M/YKbX05e+j FXAQDgxNig/UjwmDnXanLdOUqm/ko/Qt/d8HHYPWC0RliK3l+VOSC5g/hzm0vPQGMs1E HVJY4IJSoU5vIgFoueoaNxN+omG59ZXSdytccgGrQa94AoH/ZZ/tdt0bEvpiMJWKkKX9 6FdBAG5ARi6ehOkrm9lFEd6XVIaf8VYh5Wr08f786yCz/v+DIQ8vlWme3cGwXkvp2rkd zKTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=SFDVwrbuUJelLWp2gr+IHW/oKRi7ig74jRaekQfujvk=; fh=dqFyZ9vWJ986OQzhZVgKo/tQR15TBzjvRqS82/0yIGI=; b=v5miT3Wz0G3APxdRO7wMsUaceqI8WFscdgLgbfqX3ZfKUKh0wlCpkEmfOwE3LENWob sRKjRyD2aPvpv6ZS/tOBtGIL+U5m6HnM3+fpbcg/Ziv019XEe6U86i/4Vua4nRnxQTht tRbQ5Yayk2COWQMbEq1mo/eubfrqTbnVyE8ZZPRX62Z8yEctsgatcPMoZOzigQGkzfd8 ARnKLfrgvJJDDVh3+As7PpAFBe7+yhMcHZJ9GRvv7QG3oPwoEFeWQrf918v5DRKlju+C kHbF/TG+vyUtBdNMrQqt4WxhnfSx9pSX7ImKv/0WLhhkqWPshBjimb0y2uJSaUjS17vG zgYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-191952-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-579c8bfc89bsi2823537a12.349.2024.05.28.01.42.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 01:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191952-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-191952-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2ED771F21C9B for ; Tue, 28 May 2024 08:42:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C04D13C91A; Tue, 28 May 2024 08:42:19 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9388213C67D; Tue, 28 May 2024 08:42:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716885738; cv=none; b=t/NfctrccjjshZZwAo47570nQ66FA4MRT9eI2esBKAvf9agBNNub+NGvAbyxxZ0+/TUcv883gSqnNx9FhPMPEeqqLzLWMCDHo2RZax5O369ocsiL2hH3m8vPn6fu6om3agPYj8GEou67AgeIu84b5jwZJhh/ytXF4jyXZkxSxbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716885738; c=relaxed/simple; bh=6tLri2pEFjfAp0kWhBiSqF77STHOqDPuVw+K04apsJc=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=QQlZxBj5G0M7X0+AD70Md8yh003dF3n6Nzvljq6vHRACLIKFIZxKuDHWrySsb1/HK4UhJb0MQos9K5LfnK3MIpF7Iuddg5BPQfVeJK8J0YfIniOUf9u68gYgawx+eXFM8LVttwuBHKTGoIVMWvRtZYCVcy8/63WduE+3PjKVjTc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VpQrp2M27zxQvK; Tue, 28 May 2024 16:38:18 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id 41D6A180AA5; Tue, 28 May 2024 16:42:06 +0800 (CST) Received: from [10.173.135.154] (10.173.135.154) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 28 May 2024 16:42:05 +0800 Subject: Re: [linus:master] [mm] d99e3140a4: BUG:KCSAN:data-race_in_folio_remove_rmap_ptes/print_report To: David Hildenbrand , kernel test robot , Matthew Wilcox CC: , , , Andrew Morton , Vlastimil Babka , Luis Chamberlain , Muchun Song , Oscar Salvador , , References: <202405281431.c46a3be9-lkp@intel.com> <8aba80ed-7b3e-4c8c-99e8-d8a2e0b112fc@redhat.com> From: Miaohe Lin Message-ID: <4b0d996a-7499-6fce-ee19-3357f8d323cd@huawei.com> Date: Tue, 28 May 2024 16:42:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <8aba80ed-7b3e-4c8c-99e8-d8a2e0b112fc@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) On 2024/5/28 15:43, David Hildenbrand wrote: > Am 28.05.24 um 09:11 schrieb kernel test robot: >> >> >> Hello, >> >> kernel test robot noticed "BUG:KCSAN:data-race_in_folio_remove_rmap_ptes/print_report" on: >> >> commit: d99e3140a4d33e26066183ff727d8f02f56bec64 ("mm: turn folio_test_hugetlb into a PageType") >> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master >> >> [test failed on linus/master      c760b3725e52403dc1b28644fb09c47a83cacea6] >> [test failed on linux-next/master 3689b0ef08b70e4e03b82ebd37730a03a672853a] >> >> in testcase: trinity >> version: trinity-i386-abe9de86-1_20230429 >> with following parameters: >> >>     runtime: 300s >>     group: group-04 >>     nr_groups: 5 >> >> >> >> compiler: gcc-13 >> test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G >> >> (please refer to attached dmesg/kmsg for entire log/backtrace) >> >> >> we noticed this issue does not always happen. we also noticed there are >> different random KCSAN issues for both this commit and its parent. but below >> 4 only happen on this commit with not small rate and keep clean on parent. >> > > Likely that's just a page_type check racing against concurrent > mapcount changes. > > In __folio_rmap_sanity_checks() we check >     VM_WARN_ON_FOLIO(folio_test_hugetlb(folio), folio); > > To make sure we don't get hugetlb folios in the wrong rmap code path. That > can easily race with concurrent mapcount changes, just like any other > page_type checks that end up in folio_test_type/page_has_type e.g., from > PFN walkers. > > Load tearing in these functions shouldn't really result in false positives > (what we care about), but READ_ONCE shouldn't hurt or make a difference. > > > From b03dc9bf27571442d886d8da624a4e4f737433f2 Mon Sep 17 00:00:00 2001 > From: David Hildenbrand > Date: Tue, 28 May 2024 09:37:20 +0200 > Subject: [PATCH] mm: read page_type using READ_ONCE > > KCSAN complains about possible data races: while we check for a > page_type -- for example for sanity checks -- we might concurrently > modify the mapcount that overlays page_type. > > Let's use READ_ONCE to avoid laod tearing (shouldn't make a difference) > and to make KCSAN happy. > > Note: nothing should really be broken besides wrong KCSAN complaints. > > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-lkp/202405281431.c46a3be9-lkp@intel.com > Signed-off-by: David Hildenbrand LGTM. Thanks for fixing. Reviewed-by: Miaohe Lin Thanks. .