Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1565010lqb; Sun, 26 May 2024 07:01:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUqmMJh3NzVABbg8/CkyTo5zFsJUFPvcRNAGbH8pDxZ8CdT03u4//45uXv08Limg4ixji4CN4qGMRGlKtli90rNGgu5vFc1dAjtBzoOwg== X-Google-Smtp-Source: AGHT+IGigFfGQFwqitimYrFSM1ICqJfcnlKdyvBKOUZSRo68RZdne/WO7X9HIvIZbnWWSs8JoJSt X-Received: by 2002:a17:90b:188f:b0:2bd:e0dd:f232 with SMTP id 98e67ed59e1d1-2bf5e138e72mr5941467a91.8.1716732116385; Sun, 26 May 2024 07:01:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716732116; cv=pass; d=google.com; s=arc-20160816; b=gMdta1fuLD65tg+i/iQD2zQRWWhvEosMc3pT675Sb87j4x+gDZu3VoZ73hJNCRyR3M GYsjzwSyK+44Nu4U6KZ26ujvPhFL/+YY/SVw4LQMszAfJJAMh5ltYqLGcf/Tg0DpF2vE ZiPX2iDhE0fgpGp4i04OvLo3ast3wY9pxJQ+y4xdbcwk6L8dqsBdXakGy1TLesqr+4uv ooK3+gNM7Ejvc6jODVz9GAL4MnMT638q4t37km0w9vyxDORNcMvRWYEdebfI7tUr30oE jqpl2RQthUM5f21fnA5at0bNsaVQJWOjXM7YdAjFpnylGwbW1pCV/FnB5K+CvJIExbSh PK6A== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=9wWwa2blJw1v9DPCM805/uZ0DLUpVg3y4xjSDjosOAA=; fh=VELkJRHdol6dUkQTLGXPd/e4PY0ZXBRtcnsJYLmVc6s=; b=MFVJPJJDNzx+MydwhlfdT5wDZdn2xMGNLP31VPHJDRj8KbxGFfn6sghDTpOUkXb1vr 8x0qnN4An7G0/Z0NCikgL/q7hSVM7hG/UGPoM1/ygsGVQYrFbWyk8RgcVb3mEa+6tuci l3HugYy6f7RERvGV2i88RFs2hG5RSfE29umRjdinEnBYII+bCHak1WJIkY/90qp/uisI mb3YVbM7dFkaN9uanZcc/nTn55XfR4X93B1VjYPuHPm4xocncxGxkFqxl3gHfFn+9Xwg NRE99VdNqZfmopD6lyW1297IQ6Kwa2t77jXDUK/SJlAqTCalBDgnRfIqeeX16TcaOy3h vZxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BJ2r4zs2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-189748-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-682275b30f2si4587022a12.249.2024.05.26.07.01.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 07:01:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189748-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=@gmail.com header.s=20230601 header.b=BJ2r4zs2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-189748-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 BE214B20B72 for ; Sun, 26 May 2024 14:01:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B2D9168B9; Sun, 26 May 2024 14:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BJ2r4zs2" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F345115E90 for ; Sun, 26 May 2024 14:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716732108; cv=none; b=bOYqJy5cZmUxjH9XXSzhfW0BOyIB6Y547YKd8KVU4x6GIHShfSLXZp21obtKzg4MEANHklFO16wzHHDKHnhPkf+45BjDmFmO8vlJcsll5SvnxtFKhiUjXyo//ObD+QPXvyv0UWFy0rL4waFa9INBG98+b/sbGTdL+30qrz6R48E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716732108; c=relaxed/simple; bh=In48y0pApngmsbuMVu4rLDLb/XOfXDOmaT7OduNUFew=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jDJgZ0Jkt0UP5t2DjchOge31x2H2PBL6p1zuOhRqp/cg3bZ5et6ZqeCskyJs8lrVFNoCJpUI438y9Wwxc/fStj/TipnYK7rU4mclyI6zxlEc7ybuXnQ1JbYC12opRWcsbGE6AZmzdw36CpshK1jKwZR7mvXozl7bDi2hdTU/y7w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BJ2r4zs2; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1f32a24e0b2so891735ad.2 for ; Sun, 26 May 2024 07:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716732106; x=1717336906; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9wWwa2blJw1v9DPCM805/uZ0DLUpVg3y4xjSDjosOAA=; b=BJ2r4zs2spayVnniESeCaXksMNNcG3n+C3Qs5ZSsNKeTObbGjVchufMtc5I3hyUy1M AMrlfGFbzo9x9iAVB5hi+McX6sONLCSYyD33IY0jEnhG+lKUG/FOeh6qBK97u/QTGmE1 GJXYpMtWCegqiUf+5+LpSwqxA5D+y+ZhAfeqOz/jH+8DZrCxvZfgemFcAUgdzDVqXD0p JJgE/t/Wp7RHMX7KGXKo7VcQc24ajHPG5nd03j7uzw+Ox/EkmB6lEWO/estSS1CevU0G GVSbI34Z6s4NMb0E31tRpayKIOHnDafiZ4Up438L8idCARQdpGWY0vxCzXjhyRymKqT8 WmZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716732106; x=1717336906; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9wWwa2blJw1v9DPCM805/uZ0DLUpVg3y4xjSDjosOAA=; b=Ng8NJE7E1qyU3PSucRwGE2S9ZwPMcqPy7ZdLW6z6e0YCcrfu8sCoGbIOhd4a0EkUsa M8Gl8ez0hS0j1Gwvngz1Dp9dGq5jt4hhATwo8qmoWiwqthw3Rmao9ChZzMfhDHpTZPN1 vqKwhUZee3W9Y3nENNoPq5xSWWUk1mH2oj7hZe09RxJeTSdBNk/lzxwG8znmqMAR6vzN +q/1cgEddtpp9fiM1LH3DT60eT2FjS5NmDfUQNkPMDZKRWkNVxDTrLj74xfr5FKTPgt6 8NrgZFEEOzoa9OuzaTDPWD/lxNPe12fh3C+hAjnk/mr9GgtGND4QFnSAW8SHlaszszpj QprQ== X-Gm-Message-State: AOJu0YxsQaWbeZF45AQlEJTsPiwCH70y0qmeo3Rpj4U8nrjO/NKvbmCC bYErN0H3NGAqtSqjxn5PMuuOjx7ApmVH4SiVmW5t8bjMfcdoGW+583JIIQ== X-Received: by 2002:a17:903:2451:b0:1eb:50eb:c07d with SMTP id d9443c01a7336-1f4498f0cb6mr77393305ad.4.1716732106118; Sun, 26 May 2024 07:01:46 -0700 (PDT) Received: from vaxr-BM6660-BM6360.. ([2001:288:7001:2703:da5d:2d85:2879:5a6a]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f460b311f0sm31066085ad.212.2024.05.26.07.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 07:01:45 -0700 (PDT) From: I Hsin Cheng To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, I Hsin Cheng Subject: [PATCH] lib/plist.c: Enforce memory ordering in plist_check_list Date: Sun, 26 May 2024 22:01:39 +0800 Message-Id: <20240526140139.17220-1-richard120310@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit There exist an iteration over a plist in the function plist_check_list, and memory dependency exists between variables "prev", "next" and "prev->next". Consider plist is used scheduling subsystem, we should guarantee the memory order between multiple processors. Using macro "WRITE_ONCE()" can help us to ensure the memory ordering as it was stated in "/Documentation/memory-barriers.txt". Signed-off-by: I Hsin Cheng --- lib/plist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plist.c b/lib/plist.c index 0d86ed7a7..2e51829d3 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -47,8 +47,8 @@ static void plist_check_list(struct list_head *top) plist_check_prev_next(top, prev, next); while (next != top) { - prev = next; - next = prev->next; + WRITE_ONCE(prev, next); + WRITE_ONCE(next, prev->next); plist_check_prev_next(top, prev, next); } } -- 2.34.1