From patchwork Sun Mar 12 14:41:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 68356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp745087wrd; Sun, 12 Mar 2023 07:42:58 -0700 (PDT) X-Google-Smtp-Source: AK7set9m1GNdtQZPZubXQKkv/5TsPJnSFLgSzF/LU1Jw6BfvHHDJ1e4O+4iRvIf+F/oi86BvhlvB X-Received: by 2002:a05:6a00:2887:b0:5a8:aa5e:4bc3 with SMTP id ch7-20020a056a00288700b005a8aa5e4bc3mr6958266pfb.1.1678632178539; Sun, 12 Mar 2023 07:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678632178; cv=none; d=google.com; s=arc-20160816; b=UNnGDtjofyZvYgJxVwpPiODU0Ggx3Ps7TMac8t3HfXVelIHE5w1bzRxuXVuwpPz+7P 935c+gbh0Ly7m/uvloCDAlQXDMHJkAKYHuMD2tOsL9WKzhniEgltFRxxCcguKoULK+eN bZ5Iy+KubdGUmw8ODIlCkTXzbJDCHDn9jS1TaX0Sk1SHmdtMluCs0JNz3R1GiE1JhzTW hXV/rD61SiRzcLjhTqE6Jr9HAHwlijkPi0adcUTQObxxzIASIDcCxM6AZ2M7/8etwfEo EF0tjXZ15IMt60VgsoN7WAUsxZUcbxqGWKzQorPhI2q9rRXfiAa26OlXLFKsYkUnk20i B3fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ySpyZOoTqzSKRmAKJo10i+xEae61uYIC7VjmoPx3Sdk=; b=CwLC5Wo51gremMD6HnreEI5/yoirYD3J9da9YPUtk6EH2zqhuzpO1a+jGp9z2zBefQ /eoi61mTTj7SS3jHEvywtoiJCziXHtSN0TjKG6b2atFDVDOylQPzHRoh4wTU9jn09wDU G3uvklxqVqY7m4+ynor9AOrAZywxorFdJ7yREy3fQDSY8Tsn43eAIOQGuYN5v/NPZVsL tib6mLYFagu4Zzfs6Dp6O/qVCn2X6JNqOYokNA+pXXxoeS8HL6tnKXUvSubD/jrK/HNi a6MmqWPyUifCC1GpPUh3mwaBJx6DLdcZYnpCJbzar6gezp8KTFEX2+a8jkNIV4Ux4xPF 0Fag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uPLIiYrJ; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r203-20020a632bd4000000b004fabddccf93si4229444pgr.778.2023.03.12.07.42.46; Sun, 12 Mar 2023 07:42:58 -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=@linutronix.de header.s=2020 header.b=uPLIiYrJ; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbjCLOl1 (ORCPT + 99 others); Sun, 12 Mar 2023 10:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbjCLOlR (ORCPT ); Sun, 12 Mar 2023 10:41:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29A6F4393B; Sun, 12 Mar 2023 07:41:16 -0700 (PDT) Date: Sun, 12 Mar 2023 14:41:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1678632074; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ySpyZOoTqzSKRmAKJo10i+xEae61uYIC7VjmoPx3Sdk=; b=uPLIiYrJgNP5eXFvhBHoRIk1RgiHA9bFXeQresLLondz3YStZgG0sRdwU8h7XgfRBkDbwQ NJlXh0ijpeC9tPmKF47xYvX4e/gTh/Y5+VQuLKQHH+gdX7WUMnA6cUfIZwIjjT5E8ulkTj FvU7FdPGYmo5JDdmIKCbPylfxfJ3h6jkZAPRcuHtcvvXDNyd/0hpGmHdYJcGZA2N04H8bx vDbhiIlukNyJlpJogTU3o3n67Vbt6Ob8qYivgVdHGb5S0+odJX0TZtIoogJrl+H+dTiSyd qi17+m4PzZq911R5Iwsi/NbFABCCR4lnXSNRHLjN+FqYUVsbYxhuZDy/4SUsLw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1678632074; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ySpyZOoTqzSKRmAKJo10i+xEae61uYIC7VjmoPx3Sdk=; b=d5rNLZP2BhRHQIiUsKOskLLrJdT7XH2TTrLDHS7QxM/IGuyWvNX69kqaJcUxXEKUwcice4 lsACW7gQwTHklOBA== From: "tip-bot2 for Andrzej Hajda" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] io_uring: use __xchg if possible Cc: Andrzej Hajda , "Peter Zijlstra (Intel)" , Andi Shyti , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230118154450.73842-5-andrzej.hajda@intel.com> References: <20230118154450.73842-5-andrzej.hajda@intel.com> MIME-Version: 1.0 Message-ID: <167863207362.5837.13623012047790271971.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755375831348552858?= X-GMAIL-MSGID: =?utf-8?q?1760173414934195337?= The following commit has been merged into the locking/core branch of tip: Commit-ID: bd1e2670ebd10ad727b92ddd424cca270314f5ee Gitweb: https://git.kernel.org/tip/bd1e2670ebd10ad727b92ddd424cca270314f5ee Author: Andrzej Hajda AuthorDate: Wed, 18 Jan 2023 16:44:48 +01:00 Committer: Peter Zijlstra CommitterDate: Sat, 11 Mar 2023 14:03:59 +01:00 io_uring: use __xchg if possible Recently introduced helper simplifies the code. Signed-off-by: Andrzej Hajda Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Andi Shyti Link: https://lore.kernel.org/r/20230118154450.73842-5-andrzej.hajda@intel.com --- 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 fd1cc35..0cd89a3 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -1131,8 +1132,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 @@ -1141,9 +1140,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 7c198a4..051e577 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) @@ -99,10 +100,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)