Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp840925ybl; Fri, 6 Dec 2019 07:07:06 -0800 (PST) X-Google-Smtp-Source: APXvYqykEa1Nm5v3fT48HCwUSrzUveWMNbC+XKDqLT890N5I4pfneJ57TnKmg8xBRFHPL4b1v4kw X-Received: by 2002:a05:6830:4a7:: with SMTP id l7mr10718227otd.372.1575644825969; Fri, 06 Dec 2019 07:07:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575644825; cv=none; d=google.com; s=arc-20160816; b=neUeN9PK7hHQITZs/R6HtvasFl40XbkqDGe9GOqwFJizjayUmUgedFDXc5WPO+SjAq fqLZ6MzF7DdksyNsL1b2CPnCOE9rVy7ckI81tz8hFvE0y/rfkJ7T7HT1u42x6w1sHITv Ewru+e7REhXWNHZ2gK4JPC3T0auj5RhMIP0YB9C+Jg9eOCMjblBliW24pQ+3e1LyUVWc VWgyQy79dA2sNFwBw4LNk9OipYREgcUmFkSA/SO+x1c5cQQhoFQUXDvYD7Bv+nimJ8dU s4tbCZhZUfzHeho4wwVhFSmRVTJCLOUX/Ye49QH38t6x8g9wnduyZC2JVvmVHEsoOD46 PiTw== 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=NOYIo2oX0lmkpQ6gBhcLLsx1plLM1LrdnXjWaPnIOcs=; b=0rzSaTcklJGI9lByBNUXw/vurcWEUH52ZkNroh9WRmyyPc/lccLmnqUJjYHJX35zNm z2Nr2q0ibyS2Rk633CSIR7hcg41BpnDQeskFg7ViyLBfXgMalxP2CpfL9hau9fS+M5ou BmCQVCqP2/rT9wQKzcKblgJURJAvBIJ7Otk5hZSOcDQIUR37f8vwCauik1hs/o5TnrGE +fTp+SDHe6DEPfKm3/IFJRVnD1SfOfb/SN9FWDzPkc0kxQa0tfSzWBNXIx7Iyslt7zlh 98376dNFfXBjPKp6qDX0k5qPI8XnnF2nbXOhfseas+mfUevrCRYIYUc/TWWcyy91LX3U 24+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MHT26K87; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q3si7098246otk.64.2019.12.06.07.06.50; Fri, 06 Dec 2019 07:07:05 -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=@gmail.com header.s=20161025 header.b=MHT26K87; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726395AbfLFPGO (ORCPT + 99 others); Fri, 6 Dec 2019 10:06:14 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41030 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbfLFPGO (ORCPT ); Fri, 6 Dec 2019 10:06:14 -0500 Received: by mail-pf1-f194.google.com with SMTP id s18so3466541pfd.8; Fri, 06 Dec 2019 07:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=NOYIo2oX0lmkpQ6gBhcLLsx1plLM1LrdnXjWaPnIOcs=; b=MHT26K87lCwEl81XNb2/7lgyyJ+HGDXqay2wHsbsZ8dRm00ATs1ZlFFyv15xZPFJk9 nTFDr6hon+qm1IWzBdl2dwnu5BNv7BFEjw0SncsazwZgtHzfQfAFZ3GJgpPUu03DNPho qdLUwi860CeukpEZCkpGJeE9Feim2dUf5l8uHmHwIDqJlB5Fr9NH/yBlaP6XE1BYVG6x ACcn+2FDx82wMKJ4ZYOxKCxGHpg/Yt5CAOZSriNe6Eplo/gGLLAHWfyP1zfYcM7/q+y2 h5w4febplE5KwP7zNw9449T5Z6facbpeD8dG5QTIRaC2bYtPP5GyHzgSMB8Xoq/DEVnU 53aw== 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=NOYIo2oX0lmkpQ6gBhcLLsx1plLM1LrdnXjWaPnIOcs=; b=A+CY60Yx1Qe4WKYXMKjPPw+WAsX1uHsh772d/UFWJw9DgV0Yw+9VDJ4NK6uym6L+a3 kR/mcUBvxJCwNoLUTubLLKhYO9FsVKHB501OmxWj5gtbXL0qa5AtTu41JYhPQbFuPrHa jaCebaJkNBW+OmJvPC5W72yWwCHXBguO0FKgNW/aPQx5z3DzfIN6Zil8ARC6ozrF7h0m bbHGOLy/GiXduwjnAX6uXQNLlBmZ8k9N6ewGsuKV4CRcRenj93sBcfQ2bWE3BqZG2c10 YmPUdywsJuqEezoXak7DjRpiq3z+YQIm6Kguc2QTQZ+zZhP1uXKIEbqcF4Ftr05DGz7P /CPQ== X-Gm-Message-State: APjAAAUvo/YZu6crFbWaWXCczxEM9R7S4975rLJnYm/gOS+ZOuOFlLuk V/TbcGo35+IpVZi9hi2xjeU= X-Received: by 2002:a63:d54f:: with SMTP id v15mr4100489pgi.64.1575644772732; Fri, 06 Dec 2019 07:06:12 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:13a2:f129:b905:c312:4008:2416]) by smtp.gmail.com with ESMTPSA id j28sm15861041pgb.36.2019.12.06.07.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 07:06:12 -0800 (PST) From: madhuparnabhowmik04@gmail.com To: paulmck@kernel.org, rostedt@goodmis.org, joel@joelfernandes.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Madhuparna Bhowmik Subject: [PATCH] rculist: Add macro list_prev_rcu Date: Fri, 6 Dec 2019 20:35:54 +0530 Message-Id: <20191206150554.10479-1-madhuparnabhowmik04@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhuparna Bhowmik There are instances in the linux kernel where the prev pointer of a list is accessed. Unlike list_next_rcu, a similar macro for accessing the prev pointer was not present. Therefore, directly accessing the prev pointer was causing sparse errors. One such example is the sparse error in fs/nfs/dir.c error: fs/nfs/dir.c:2353:14: error: incompatible types in comparison expression (different address spaces): fs/nfs/dir.c:2353:14: struct list_head [noderef] * fs/nfs/dir.c:2353:14: struct list_head * The error is caused due to the following line: lh = rcu_dereference(nfsi->access_cache_entry_lru.prev); After adding the macro, this error can be fixed as follows: lh = rcu_dereference(list_prev_rcu(&nfsi->access_cache_entry_lru)); Therefore, we think there is a need to add this macro to rculist.h. Suggested-by: Joel Fernandes (Google) Signed-off-by: Madhuparna Bhowmik --- include/linux/rculist.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/rculist.h b/include/linux/rculist.h index 4b7ae1bf50b3..49eef8437753 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -40,6 +40,12 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list) */ #define list_next_rcu(list) (*((struct list_head __rcu **)(&(list)->next))) +/* + * return the prev pointer of a list_head in an rcu safe + * way, we must not access it directly + */ +#define list_prev_rcu(list) (*((struct list_head __rcu **)(&(list)->prev))) + /* * Check during list traversal that we are within an RCU reader */ -- 2.17.1