From patchwork Wed Jan 18 15:44:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 45346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2409040wrn; Wed, 18 Jan 2023 07:47:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXvTMJQYBw2s4oNWZKxc7UlfX9pFc5BRHkjKZS1dhuilB5arLaRabbtPgqqAfCfqNlzvdqXe X-Received: by 2002:a05:6402:1c0c:b0:499:46c0:1269 with SMTP id ck12-20020a0564021c0c00b0049946c01269mr7127027edb.14.1674056846278; Wed, 18 Jan 2023 07:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674056846; cv=none; d=google.com; s=arc-20160816; b=r7XLtVv0grbYydf2brz9oshsEJ/hNHFHX1g57T9rAvynW3D6encQYy1BFwXy9gAlml +E6FiqvjYw5eXWCOSB3nLaCJJI7Shb7V5b9QFueyWPddMvm7dr8QTXF12wr5N3gPlVfK hFLjectxhR6C+7WjilC6umBnPj7HBsE8Tp0D+h7yQFPmNpv7XobKmRQ9CMlZ3np/Ewjg aeOWm4NPZWQybdqFMc5CiX8r0pjbh5nq8m1s/zxVUDZo1jxAzo8io5IreLKfJMU/C0Uy P4HM7kSknAnzcCeoeAsWmAtg4Fj0phVHeN5IPYxCt0ZUNBIRTqOnVjRPvCWcdS4RFaX1 eSnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dqcYj7/0ziyyKrcLniIaF5s3gmmIt8WaJWsLAVTgOfo=; b=wPZEg57tsmRvd3v8HWoCwDAmaEGRkLM9yk2Sz6Jz7n7Fb512NVmTiFeQGXcvQVaqXd y3aVh3Rla1mgnjw/z9c3v9G6EtiiZ1HwNr5HxjwXRHSfvmF199cpV24Bbgsqm6K7j8HH OzqwwoJeeGLnhYHVrlCHjzLDTrMAFoYqQjA+qyCI1WNDoPaK0zpZJOkYJ5iit8TbvYbh nDayNbGp19/i/IWW/znAbXCyLiquaE7K3LrLxMVHybSWyAjxgaCK2bK9E/4vT7V58czt DrO8Pg8fD1mzNGBIUGVkYzTs2KjB/50URWovSM305kZtGBXjBDmF9DQZT9dUDBPex1kN i/NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kUt88PFk; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a056402268600b0049e420baaeesi5480188edd.470.2023.01.18.07.47.01; Wed, 18 Jan 2023 07:47:26 -0800 (PST) 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=@intel.com header.s=Intel header.b=kUt88PFk; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231232AbjARPqn (ORCPT + 99 others); Wed, 18 Jan 2023 10:46:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230454AbjARPqE (ORCPT ); Wed, 18 Jan 2023 10:46:04 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 910033757D; Wed, 18 Jan 2023 07:45:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674056736; x=1705592736; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r4W7l/3g2FF9m+Bbn+8NEkNQ+AUW9MsI1xwl1GBeVcA=; b=kUt88PFkfsOJ3giMyl1qJ69QOXxX8r8xqbhHBG5+LCcHDLHdA1Az/UOB OvGB8c9tJVQzXLI7norMldebbnRo5829I91RzWm300IXr84AtYmTc/xO1 pSLfeZlYoWnxeep//m3gNvJoZs5IYdC0jbCVX8o/SVFlWvaDCJJzSidk8 GhYQ6QUGV462c3a6pB1c/UUGAA+KxURlkN4cjm5yEyrSWRiM88mZ4Mt5w xUu4skEXgxpVlD+QQPaegoo/0C3TyRkS4Ob164OvzgbA4tTm1u+LI1J69 +ScGwodxNqwOoamfhhoD+KlrCT9cEoeJHbQfvXngPNDSfalV8zekXpPYB Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="322701355" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="322701355" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 07:45:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="661759365" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="661759365" Received: from lab-ah.igk.intel.com ([10.102.42.211]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 07:45:30 -0800 From: Andrzej Hajda To: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Andrzej Hajda , Arnd Bergmann , Rodrigo Vivi , Andrew Morton , Andy Shevchenko , Peter Zijlstra , Boqun Feng , Mark Rutland Subject: [PATCH v5 5/7] io_uring: use __xchg if possible Date: Wed, 18 Jan 2023 16:44:48 +0100 Message-Id: <20230118154450.73842-5-andrzej.hajda@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118154450.73842-1-andrzej.hajda@intel.com> References: <20230118153529.57695-1-andrzej.hajda@intel.com> <20230118154450.73842-1-andrzej.hajda@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755375831348552858?= X-GMAIL-MSGID: =?utf-8?q?1755375831348552858?= Recently introduced helper simplifies the code. Signed-off-by: Andrzej Hajda Reviewed-by: Andi Shyti --- io_uring/io_uring.c | 7 ++----- io_uring/slist.h | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 2ac1cd8d23ea62..2b46a692d69022 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -1095,8 +1096,6 @@ static void __io_req_find_next_prep(struct io_kiocb *req) static inline struct io_kiocb *io_req_find_next(struct io_kiocb *req) { - struct io_kiocb *nxt; - /* * If LINK is set, we have dependent requests in this chain. If we * didn't fail this request, queue the first one up, moving any other @@ -1105,9 +1104,7 @@ static inline struct io_kiocb *io_req_find_next(struct io_kiocb *req) */ if (unlikely(req->flags & IO_DISARM_MASK)) __io_req_find_next_prep(req); - nxt = req->link; - req->link = NULL; - return nxt; + return __xchg(&req->link, NULL); } static void ctx_flush_and_put(struct io_ring_ctx *ctx, bool *locked) diff --git a/io_uring/slist.h b/io_uring/slist.h index f27601fa46607b..d3a743a1adc626 100644 --- a/io_uring/slist.h +++ b/io_uring/slist.h @@ -2,6 +2,7 @@ #define INTERNAL_IO_SLIST_H #include +#include #define wq_list_for_each(pos, prv, head) \ for (pos = (head)->first, prv = NULL; pos; prv = pos, pos = (pos)->next) @@ -121,10 +122,7 @@ static inline void wq_list_del(struct io_wq_work_list *list, static inline struct io_wq_work_node *wq_stack_extract(struct io_wq_work_node *stack) { - struct io_wq_work_node *node = stack->next; - - stack->next = node->next; - return node; + return __xchg(&stack->next, stack->next->next); } static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)