From patchwork Thu Sep 12 10:49:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13801891 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3449C19E980 for ; Thu, 12 Sep 2024 10:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726138203; cv=none; b=uCUtwLvZDJHdVqFWG3prr3m4mfGact1z2j1B+DtIKWTQVdZPp/tdVxjsb6Er1PJXKPIZV4cTW7a5lvtNPPfT1+I/QFed/647cUvj1HkjVBBFKymwM1P7yOWzNPUddsqLKNJklnSSgWfD9Nq6dhvm8e4EGZY2zt0db71guvjBhYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726138203; c=relaxed/simple; bh=fibGHx1OvVqy14tS29/cRRU9u/bGIgQCHm8EDZb2KZw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l0mM2qzTNAnVb+v4SySUheW/PZHwHdlzOpe6WPtVUCBu3soBhyBvKqlfFc8eyJCVsbdPCnXQtSI7UtiH9FVTpFq+/FVk/yGoZxVxBpnrRSR0DkHIDLR1GExAT5AtEF3Nch7xsIIatml3l7GNZtlHoLNDWjJAW6SreNWKe9/ABQo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BP+lSNPk; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BP+lSNPk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726138201; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=poTNcxeG0HyUE1F2Mp5betsd6Opaxgkm0Xuldr0SxaY=; b=BP+lSNPkj7uhJw5oF0En0EgyjEq0OAhdaQyPFcW9WNUy8aVNZ1fEmjabhvePxPWTPZnhhC iC+CQi+41JnU8rBrMWuuRMGELMsaFxw2akKxHoQm2QEBxL9iQd7v8a767ltMU/pY0r+GlR 2sgwuqw5VyXVU7D1cO3PLpUnRisQ+RM= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-193-uv2Mio6xOTuViCOyEi2_lA-1; Thu, 12 Sep 2024 06:49:57 -0400 X-MC-Unique: uv2Mio6xOTuViCOyEi2_lA-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1D7F21955D47; Thu, 12 Sep 2024 10:49:56 +0000 (UTC) Received: from localhost (unknown [10.72.116.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1765519560AB; Thu, 12 Sep 2024 10:49:54 +0000 (UTC) From: Ming Lei To: Jens Axboe , io-uring@vger.kernel.org, Pavel Begunkov Cc: linux-block@vger.kernel.org, Ming Lei Subject: [PATCH V6 3/8] io_uring: add helper of io_req_commit_cqe() Date: Thu, 12 Sep 2024 18:49:23 +0800 Message-ID: <20240912104933.1875409-4-ming.lei@redhat.com> In-Reply-To: <20240912104933.1875409-1-ming.lei@redhat.com> References: <20240912104933.1875409-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Add helper of io_req_commit_cqe() for simplifying __io_submit_flush_completions() a bit. No functional change, and the added helper will be reused in sqe group code with same lock rule. Signed-off-by: Ming Lei --- io_uring/io_uring.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 7454532d0e8e..d277f0a6e549 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -861,6 +861,20 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags) return posted; } +static __always_inline void io_req_commit_cqe(struct io_ring_ctx *ctx, + struct io_kiocb *req) +{ + if (unlikely(!io_fill_cqe_req(ctx, req))) { + if (ctx->lockless_cq) { + spin_lock(&ctx->completion_lock); + io_req_cqe_overflow(req); + spin_unlock(&ctx->completion_lock); + } else { + io_req_cqe_overflow(req); + } + } +} + static void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags) { struct io_ring_ctx *ctx = req->ctx; @@ -1413,16 +1427,8 @@ void __io_submit_flush_completions(struct io_ring_ctx *ctx) struct io_kiocb *req = container_of(node, struct io_kiocb, comp_list); - if (!(req->flags & REQ_F_CQE_SKIP) && - unlikely(!io_fill_cqe_req(ctx, req))) { - if (ctx->lockless_cq) { - spin_lock(&ctx->completion_lock); - io_req_cqe_overflow(req); - spin_unlock(&ctx->completion_lock); - } else { - io_req_cqe_overflow(req); - } - } + if (!(req->flags & REQ_F_CQE_SKIP)) + io_req_commit_cqe(ctx, req); } __io_cq_unlock_post(ctx);