Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3076940rwb; Mon, 15 Aug 2022 17:33:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR73KuspjFEY8BWevVw+r9O5AI3gRTYWDne7RlPSWOEHb9MvwoB9cnOL6OpIkeZGUL1NYAOL X-Received: by 2002:a17:906:84ef:b0:731:82a8:ea03 with SMTP id zp15-20020a17090684ef00b0073182a8ea03mr11911604ejb.462.1660609993904; Mon, 15 Aug 2022 17:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660609993; cv=none; d=google.com; s=arc-20160816; b=WApY+WOCLl17/BJF4oeUnjXprWsbXr9nAe+L/7ngcG5QzpowvRH9XzTMKf3PEYeyBZ dqLSyWhe5Wy4J7zCZLLF/n45D4FWddmT38ZsD0ygO/d8e5KJ5MUpJkytbx3wfmP/c8Lg sX0G2Snz08r91ZwGjPM4YSSpHljwpOfcWWSoq9D5IB03tUy7AMEjWZdoXVFCxZTx1Cjp TujZWeQ1o7GUDOwau1VdESn9WN+PAou46K7HJnzJGU7Ma1ApT5URDrerNTQjDkixllHs uVea+uN2s0gicbI76Zu+WyAeHRXkHRXrp4tAyz7eJ/4Fl19oSSqKwNLijxpS7tRNR6pW hqTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qdU7CUUlDVBDVzLlKej0G8pXw9EeVp1KqEW24nYrAZA=; b=LzYYa27qya/5wSGOITfXAwuiYUe+ZdN66YVeV2Py7SChYHx4mMtcNMJlRaxDajluT4 fPEzB2HyX40PJ6AAOiO0eVC26YgL2s88W5PkF8cOatB6HsAiDMIUgTsE1xNrrM5tYc7z pAZFJdp89gt7Eze64Tdc/uQkssZ8+v/PM84gGJ6aNS+xL+/j0FGv3muyRxTqlBLV/Uk+ rS1J58mO+K10ybuiqIAig9ATJrK0ptkXLRcpym1zsdpV6L4J5O0pItXFq/HHWKI5CeeZ 4EHqamt/H17jylOgELz48Ij5NKeZh2DnlyErvSg56aRDyLQoszqskZhofj/v9dLWd2cV OPJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wreLAwM4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh13-20020a1709076e8d00b00726b4f91300si8049764ejc.269.2022.08.15.17.32.47; Mon, 15 Aug 2022 17:33:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wreLAwM4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347064AbiHOWNP (ORCPT + 99 others); Mon, 15 Aug 2022 18:13:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348757AbiHOWLS (ORCPT ); Mon, 15 Aug 2022 18:11:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 146AB11B4CD; Mon, 15 Aug 2022 12:38:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1DC15B80EA8; Mon, 15 Aug 2022 19:38:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B977C433C1; Mon, 15 Aug 2022 19:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592309; bh=Yd5JxsAxvVeLl/3MUyNfL0UzpXOtZWTk0Y5/jmYbEdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wreLAwM4ePuSCU3AG8Qzq5scrUUnmL2yFS/iVa9ORpwG2LONRxjuFTcZlksx7BXX/ ZDM/+QmTHhagr0t/tMT4ifiOqr8YREvVTSnudvcgE/SkBXhDn7z/vNw/IrwGnuDLlQ MAsBCjqwKPzMCMe6gHbFo+Xbuffi3iQn3F2r8aH4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, jinpu.wang@ionos.com, Md Haris Iqbal , Jason Gunthorpe , Leon Romanovsky , Sasha Levin Subject: [PATCH 5.18 0768/1095] RDMA/rtrs-clt: Replace list_next_or_null_rr_rcu with an inline function Date: Mon, 15 Aug 2022 20:02:47 +0200 Message-Id: <20220815180501.030172119@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Md Haris Iqbal [ Upstream commit c14adff285ad1bb8eefc5d8fc202ceb1f7e3a2f1 ] removes list_next_or_null_rr_rcu macro to fix below warnings. That macro is used only twice. CHECK:MACRO_ARG_REUSE: Macro argument reuse 'head' - possible side-effects? CHECK:MACRO_ARG_REUSE: Macro argument reuse 'ptr' - possible side-effects? CHECK:MACRO_ARG_REUSE: Macro argument reuse 'memb' - possible side-effects? Replaces that macro with an inline function. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Cc: jinpu.wang@ionos.com Link: https://lore.kernel.org/r/20220712103113.617754-5-haris.iqbal@ionos.com Signed-off-by: Md Haris Iqbal Suggested-by: Jason Gunthorpe Signed-off-by: Jack Wang Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 35 ++++++++++++-------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index c2c860d0c56e..65bad1dd917b 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -740,25 +740,25 @@ struct path_it { struct rtrs_clt_path *(*next_path)(struct path_it *it); }; -/** - * list_next_or_null_rr_rcu - get next list element in round-robin fashion. +/* + * rtrs_clt_get_next_path_or_null - get clt path from the list or return NULL * @head: the head for the list. - * @ptr: the list head to take the next element from. - * @type: the type of the struct this is embedded in. - * @memb: the name of the list_head within the struct. + * @clt_path: The element to take the next clt_path from. * - * Next element returned in round-robin fashion, i.e. head will be skipped, + * Next clt path returned in round-robin fashion, i.e. head will be skipped, * but if list is observed as empty, NULL will be returned. * - * This primitive may safely run concurrently with the _rcu list-mutation + * This function may safely run concurrently with the _rcu list-mutation * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock(). */ -#define list_next_or_null_rr_rcu(head, ptr, type, memb) \ -({ \ - list_next_or_null_rcu(head, ptr, type, memb) ?: \ - list_next_or_null_rcu(head, READ_ONCE((ptr)->next), \ - type, memb); \ -}) +static inline struct rtrs_clt_path * +rtrs_clt_get_next_path_or_null(struct list_head *head, struct rtrs_clt_path *clt_path) +{ + return list_next_or_null_rcu(head, &clt_path->s.entry, typeof(*clt_path), s.entry) ?: + list_next_or_null_rcu(head, + READ_ONCE((&clt_path->s.entry)->next), + typeof(*clt_path), s.entry); +} /** * get_next_path_rr() - Returns path in round-robin fashion. @@ -789,10 +789,8 @@ static struct rtrs_clt_path *get_next_path_rr(struct path_it *it) path = list_first_or_null_rcu(&clt->paths_list, typeof(*path), s.entry); else - path = list_next_or_null_rr_rcu(&clt->paths_list, - &path->s.entry, - typeof(*path), - s.entry); + path = rtrs_clt_get_next_path_or_null(&clt->paths_list, path); + rcu_assign_pointer(*ppcpu_path, path); return path; @@ -2277,8 +2275,7 @@ static void rtrs_clt_remove_path_from_arr(struct rtrs_clt_path *clt_path) * removed. If @sess is the last element, then @next is NULL. */ rcu_read_lock(); - next = list_next_or_null_rr_rcu(&clt->paths_list, &clt_path->s.entry, - typeof(*next), s.entry); + next = rtrs_clt_get_next_path_or_null(&clt->paths_list, clt_path); rcu_read_unlock(); /* -- 2.35.1