Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2528070lqo; Tue, 14 May 2024 01:04:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX90/eOiiY7wNkr7vS/9khM+T3fgkL2hs985IJt3CcAWXv2Bhf7/AYeqENDgTrM6/2TULgfe3mVyhDBHBeBKD8WmgVIhjcv3S12Jacn7Q== X-Google-Smtp-Source: AGHT+IEFrextc3cYi3dqxnkFwraNqsLaOwi+Hc3y6ZWZ8CEk9A55DxvqNYY11uYs0++OTlcr2C8T X-Received: by 2002:a17:902:d586:b0:1ef:44d9:4183 with SMTP id d9443c01a7336-1ef44d941b6mr149326715ad.63.1715673885120; Tue, 14 May 2024 01:04:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715673885; cv=pass; d=google.com; s=arc-20160816; b=oB3ifHG1VIIf1Hu+6rI/YjzM00gtqb1gF4/u6SiFYtb4IboDAyiI+lX83Is/SvtlyW YHjaRafEBG5nPR1GEd5wLEbr2Z1VcEe9MGRix9wLOKzFHHh3ZkOU9G8QdnW/Gz8FJiMt Apkq/zg9vTdlaCGryCciMFe4bukw4IhVnxseMOegW0lEBIAEXvaVa53Wf6oMKFyENBKx NfmxXANdFXdXFY+N228AhE1OWO+AN39pDuSimj2MURNoxCbRJQrKd8Vypw7Z5zQPolXL Hr/afj6mOcu2iXGRwtxYGRyKKElhe/bqdwtyZuJbIjwWtgGeyrTHm05y/ioN27pHUp8c dcBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LcoPiPQ2cDUD3ccUoUxr3vfIIU5y5RPZcbdajwyHnz0=; fh=rE0Htg71XJqENQMwn6kUUAVNhDsMpXC8q5Yej/EA4iQ=; b=trEqa2VnvToXUjUFR944aQk1aCD8nl+KrTBnuAqe8QtwXo+OUMo9cqDLZQerr8dXp7 Wd0gecDpUwPnm1XjAjsI56Fp0m/La9LMfk4GfHi3JymXHtfpmopz9s8vDPC5QB8RwJYD FQzxLkD4nDiCIPY98fPn7bbYmta1F6EYKymxoNrp/MJhxMRJr82/RyxOWOGiPXsgouBg kuMIdugG5VQf2G3z++np1tTRpMu46Cgf51/p8Flaw3ySA3YskmZvaL1Zq7ebX3tpRlwX NEosOUCdJVVV4py7tB/QLOY5sa9TziZ9x2qRSrPYSkjraNhb90lo/S3VpoYTblx8Qe08 IefA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=RG06WhbQ; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-178424-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178424-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0b9cff98si111248525ad.72.2024.05.14.01.04.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 01:04:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178424-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=RG06WhbQ; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-178424-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178424-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D029AB20D1F for ; Tue, 14 May 2024 08:04:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D27D1CA92; Tue, 14 May 2024 08:04:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="RG06WhbQ" Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4AFF1125A9 for ; Tue, 14 May 2024 08:04:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.2 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715673870; cv=none; b=XfCw5xyKiRZJ+TanNHLST5mOLXJx1Rvc8xKS4qkDvr39rLQ1sGEnB5dk213OOK1NwFFlb4LecmXKAwQPy5IujrJ4UX2juTkg+Ifgv5K11cj8RmIA8PWeepaDbpilZJxmTks0me9JrQWAPTG6OvCz23awN2eaeR3aghw2VXByhHY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715673870; c=relaxed/simple; bh=wLm0Vj2eXCxBqcyOp4WaiFBvPsGqeQBJRznZMy7avE8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DHt9hKMsi6qJS9XnefW5RYR9PdZydaPqiS5rUcthPpXQK/E5fpw1yPjgC8D5bIuNN9j3g9VS8t7k4CpszW0nba1DyjLt9l+Q+mEy/lOiuOpDHPLy+m7N9cgMm17wwrNSxkckfOK+kljOpyc5ClqxBTDstkP990R/WxrpS1ODnF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=RG06WhbQ; arc=none smtp.client-ip=220.197.31.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=LcoPi PQ2cDUD3ccUoUxr3vfIIU5y5RPZcbdajwyHnz0=; b=RG06WhbQC0xG44q2ERcuC kLGOl2gXC1yqM69A9+g8+n2ej7v/Qr1Utb5Nd4M99JL864bVd9aPT9/FTLLYFkH6 sAbzLcJURcIahfkRARXHhhDmjOlIQPHjdNrjzruAzM32eOFYkf/CDOKv3bxHUDXo xPFSZGDS4jwVyHo0hlScEw= Received: from localhost.localdomain (unknown [193.203.214.57]) by gzga-smtp-mta-g3-2 (Coremail) with SMTP id _____wDnbyXAGkNmjzzvEQ--.15827S4; Tue, 14 May 2024 16:03:13 +0800 (CST) From: ran xiaokai To: shy828301@gmail.com Cc: akpm@linux-foundation.org, david@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, xu.xin16@zte.com.cn, ziy@nvidia.com Subject: Re: [PATCH linux-next] mm/huge_memory: mark racy access on huge_anon_orders_always Date: Tue, 14 May 2024 08:03:12 +0000 Message-Id: <20240514080312.661480-1-ranxiaokai627@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wDnbyXAGkNmjzzvEQ--.15827S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cw1kWr4DKr1xZF17tFykGrg_yoW8XF13pF 97GF1xCa48Zr9IkrW2ya17AryrXrZxGa4Uur1Sg3ZFyasxtr1vvr18Z34ak3Z8Zr9Fya1S 9Fy7Was5Can8XaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U3-BiUUUUU= X-CM-SenderInfo: xudq5x5drntxqwsxqiywtou0bp/xtbB0gTeTGWXxu8VaAAAsi >> >> From: Ran Xiaokai >> >> huge_anon_orders_always and huge_anon_orders_always are accessed >> lockless, it is better to use the READ_ONCE() wrapper. >> This is not fixing any visible bug, hopefully this can cease some >> KCSAN complains in the future. > > A little bit confused here. Did you see complaints from KCSAN? Not yet. The only written access to huge_anon_orders_always is when changing the mTHP sysfs "enabled" knob, I think peple do not change the mTHP settings frequently. But the possibility is not zero, please refer to the cgroup related knobs, I think wde'd better do the same and this annotation wont lead to any performance issue, right? >> Also do that for huge_anon_orders_madvise. >> >> Signed-off-by: Ran Xiaokai >> --- >> include/linux/huge_mm.h | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h >> index de0c89105076..6573430ea600 100644 >> --- a/include/linux/huge_mm.h >> +++ b/include/linux/huge_mm.h >> @@ -122,8 +122,8 @@ static inline bool hugepage_flags_enabled(void) >> * So we don't need to look at huge_anon_orders_inherit. >> */ >> return hugepage_global_enabled() || >> - huge_anon_orders_always || >> - huge_anon_orders_madvise; >> + READ_ONCE(huge_anon_orders_always) || >> + READ_ONCE(huge_anon_orders_madvise); >> } >> >> static inline int highest_order(unsigned long orders)