From patchwork Mon Dec 16 20:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910516 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD0491D5AB7 for ; Mon, 16 Dec 2024 20:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734381993; cv=none; b=i4zvWXXxgYNyHFnfiYYy3imOsQsPejp3IMmeFXQvow7fwS83nTGMI6usmhEoBxpRZQVBqZZN8sNwjVQ+m8yCRdqnBl1v/zhgORGlx1/WOfXxTphy9Xz+NefxA4mRkNfrQu0gtswgRD8XVzi5Loe5NYxSu4+8UOz2lOi229eyigY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734381993; c=relaxed/simple; bh=BBaMLGHJfK2NjRYV4grWKBmxae8Q/AOnhL16FkoD8tI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WnRNTfbKu5J21b9AXvGQxhpi+k+qARS4SJCGb7rnr+5HWRjXeu2UKO+Q2bOlFBJ13FoaS08ivk13Q7Ij61dkIx48tMl7qfsLJMmDQKzzq/X8/QABB8TJqADpA57H2rTpCyISJk7svIcAwTCYdH0nRZCP1sXpbFwC2wliI47jB4Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=DdsiPTfH; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=aVV0+N5y; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=DdsiPTfH; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=aVV0+N5y; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="DdsiPTfH"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="aVV0+N5y"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="DdsiPTfH"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="aVV0+N5y" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B9B2D21120; Mon, 16 Dec 2024 20:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734381989; h=from:from:reply-to: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=/287T9g3gFxMclWhQz7JGBexhglTHPIXP8sYh5trkAE=; b=DdsiPTfHNjpnjaNRoNL22C3y5NsKfdQvV5C80U0zhCh808fWTdUf6ASTst9vLbnjdD36iL Lr0iF1ytKz7E2RnO2tg+TxVGBGF1/tBC4QPSIJz3Y8g1QkO9+bPhTnn/6gGjHMd4/Ij92a eEMEJztZbZlZojlCIgvXKKjdqgREUMM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734381989; h=from:from:reply-to: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=/287T9g3gFxMclWhQz7JGBexhglTHPIXP8sYh5trkAE=; b=aVV0+N5yA6P344VxEZztcQY9A88b1jlVkvdJ/+IXwWSOHRAF8Nqs1Cs4n05HO+xjGiKSDc eiakw91Hx1rB8KAQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734381989; h=from:from:reply-to: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=/287T9g3gFxMclWhQz7JGBexhglTHPIXP8sYh5trkAE=; b=DdsiPTfHNjpnjaNRoNL22C3y5NsKfdQvV5C80U0zhCh808fWTdUf6ASTst9vLbnjdD36iL Lr0iF1ytKz7E2RnO2tg+TxVGBGF1/tBC4QPSIJz3Y8g1QkO9+bPhTnn/6gGjHMd4/Ij92a eEMEJztZbZlZojlCIgvXKKjdqgREUMM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734381989; h=from:from:reply-to: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=/287T9g3gFxMclWhQz7JGBexhglTHPIXP8sYh5trkAE=; b=aVV0+N5yA6P344VxEZztcQY9A88b1jlVkvdJ/+IXwWSOHRAF8Nqs1Cs4n05HO+xjGiKSDc eiakw91Hx1rB8KAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7F8EA137CF; Mon, 16 Dec 2024 20:46:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id yD/cGKWRYGfbZAAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:29 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 1/9] io_uring: Fold allocation into alloc_cache helper Date: Mon, 16 Dec 2024 15:46:07 -0500 Message-ID: <20241216204615.759089-2-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -5.30 X-Spam-Flag: NO The allocation paths that use alloc_cache duplicate the same code pattern, sometimes in a quite convoluted way. Fold the allocation into the cache code itself, making it just an allocator function, and keeping the cache policy invisible to callers. Another justification for doing this, beyond code simplicity, is that it makes it trivial to test the impact of disabling the cache and using slab directly, which I've used for slab improvement experiments. One relevant detail is that we provide a callback to optionally initialize memory only when we actually reach slab. This allows us to avoid blindly executing the allocation with GFP_ZERO and only clean fields when they matter. Signed-off-by: Gabriel Krisman Bertazi --- since v1: - add a callback to initialize objects coming from slab - rename io_alloc_cache_alloc -> io_cache_alloc --- io_uring/alloc_cache.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/io_uring/alloc_cache.h b/io_uring/alloc_cache.h index b7a38a2069cf..a3a8cfec32ce 100644 --- a/io_uring/alloc_cache.h +++ b/io_uring/alloc_cache.h @@ -30,6 +30,19 @@ static inline void *io_alloc_cache_get(struct io_alloc_cache *cache) return NULL; } +static inline void *io_cache_alloc(struct io_alloc_cache *cache, gfp_t gfp, + void (*init_once)(void *obj)) +{ + if (unlikely(!cache->nr_cached)) { + void *obj = kmalloc(cache->elem_size, gfp); + + if (obj && init_once) + init_once(obj); + return obj; + } + return io_alloc_cache_get(cache); +} + /* returns false if the cache was initialized properly */ static inline bool io_alloc_cache_init(struct io_alloc_cache *cache, unsigned max_nr, size_t size) From patchwork Mon Dec 16 20:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910517 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B6D11D0E26 for ; Mon, 16 Dec 2024 20:46:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734381994; cv=none; b=MqfWL73ZDjGCn6NS7ObaZ4cXnvB1cURzRwBRLiuWgLq4jYpSSNiQv+AU6yL5hQxCg8e3+9pD7F+AmAideojFsNpiyn7K6A1/qg1if10WmgXeVTCJxjGEJ8wi2goGrt42FtnWvbqTpTf+OfDsd+fOmipijFNs52HdY5jWr+zjR6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734381994; c=relaxed/simple; bh=6id6AWdRZMb1HMZ1jX4utNWInmMtEe8b4LL6wdSyBwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j+Pac0x7o1t55KVyW2omN2+1G2DDHzkBeH6MzYToLTyvB2TbeKnI+Rjf+u8uJ7V+rMxm/+lMvu0ha20KfEb57hjvd3+nchadXO9F0Di7kicqpoqyBUXfk5KDCBrGo1yZSkopi6du34Ln1k9BOrfHZK+v1nhshV7qpahD6poHZ+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=vrDAFRQ4; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UbZYN3F+; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=vrDAFRQ4; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UbZYN3F+; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="vrDAFRQ4"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UbZYN3F+"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="vrDAFRQ4"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UbZYN3F+" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6259C2111F; Mon, 16 Dec 2024 20:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734381991; h=from:from:reply-to: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=TQOa2byvDqO6GB87pBRBG7/hj3M2AXVfopBemjXfnig=; b=vrDAFRQ4TWwiY9Z5zIlALpCVHFbuovIeQdoU6UYveYfDnIYQbMlBrkunchQrRzCF5e3vHh gGVqikXzC94/ZfvSXWHWJHdSHvGGucgbByv3EAjZXPIo+9YglpiV7d0ZS1hGp29/MUYvHZ UxNZ6dsYzVMmxiiScke4nFh/7FcRjl4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734381991; h=from:from:reply-to: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=TQOa2byvDqO6GB87pBRBG7/hj3M2AXVfopBemjXfnig=; b=UbZYN3F+iW72rqNoWAtgVDW7gi7kSrc2CX8OO1Bfn1HoVQ3njCF5c6xcX//AtzgHf4JM7H Dm+5VOIzSNWKxyAA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734381991; h=from:from:reply-to: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=TQOa2byvDqO6GB87pBRBG7/hj3M2AXVfopBemjXfnig=; b=vrDAFRQ4TWwiY9Z5zIlALpCVHFbuovIeQdoU6UYveYfDnIYQbMlBrkunchQrRzCF5e3vHh gGVqikXzC94/ZfvSXWHWJHdSHvGGucgbByv3EAjZXPIo+9YglpiV7d0ZS1hGp29/MUYvHZ UxNZ6dsYzVMmxiiScke4nFh/7FcRjl4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734381991; h=from:from:reply-to: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=TQOa2byvDqO6GB87pBRBG7/hj3M2AXVfopBemjXfnig=; b=UbZYN3F+iW72rqNoWAtgVDW7gi7kSrc2CX8OO1Bfn1HoVQ3njCF5c6xcX//AtzgHf4JM7H Dm+5VOIzSNWKxyAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2B8EB137CF; Mon, 16 Dec 2024 20:46:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id LCGjBKeRYGffZAAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:31 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 2/9] io_uring: Add generic helper to allocate async data Date: Mon, 16 Dec 2024 15:46:08 -0500 Message-ID: <20241216204615.759089-3-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -5.30 X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Level: This helper replaces io_alloc_async_data by using the folded allocation. Do it in a header to allow the compiler to decide whether to inline. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/io_uring.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index 12abee607e4a..cd7bf71574e4 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -222,6 +222,16 @@ static inline void io_req_set_res(struct io_kiocb *req, s32 res, u32 cflags) req->cqe.flags = cflags; } +static inline void *io_uring_alloc_async_data(struct io_alloc_cache *cache, + struct io_kiocb *req, + void (*init_once)(void *obj)) +{ + req->async_data = io_cache_alloc(cache, GFP_KERNEL, init_once); + if (req->async_data) + req->flags |= REQ_F_ASYNC_DATA; + return req->async_data; +} + static inline bool req_has_async_data(struct io_kiocb *req) { return req->flags & REQ_F_ASYNC_DATA; From patchwork Mon Dec 16 20:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910518 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AACD81D434F for ; Mon, 16 Dec 2024 20:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734381996; cv=none; b=Q2XVFJridmjBokkNrNHNAq47hDBz2BVHX2I2qMcC1givXsCF5a+89S5Zhl0H+48NAqB2M5d2enqmgiAlerz6T8xXALUwU34X71/5/w19H/jJJdqWLC+Oh4S7jMTDp65RsSfAr31q8bzJj6MXDSKZ5ak3MZek4iy6eixwya+HFUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734381996; c=relaxed/simple; bh=kFBkDnSnEZZ1VfI5FksgAvdRIAP5QPxLBN+/Yu2XlRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mTn2ZL8Z4jdSTFZO02i+3zO4w/INUKmxLAiXhof2ZbRdj8rHpUuC/ESLvhTs3LzXHuOUwcdz3kvhDhYkji5xygySzvKv7KitaPkMGsvkX6J26yFoluTPHHGdz9ouh5YoO28bSiXlUtnQBGRstloR3B33E0ztqrJxQtAAdbtqx6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Fq8ab15z; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=rWCymyrt; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Fq8ab15z; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=rWCymyrt; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Fq8ab15z"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="rWCymyrt"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Fq8ab15z"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="rWCymyrt" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2B59E1F37E; Mon, 16 Dec 2024 20:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734381993; h=from:from:reply-to: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=Zf3j+7x8OWqZs5Flqu4Qd02MEQlkGNkjLaHkJZbmiPk=; b=Fq8ab15zLwMJeAcPPchg2JxEmVpMu7TNStBTYe+WK7joiuL2w08lSnO6e2fT8N0aYgUN3w S6r+Z0G+a+zvcqQVKfd71OYRQeKEWh+0XbBYmJ6gY/qXl40vYAp2ktK3J32eAkONhNYKiS nwjqmjiCXPjqFIE46zgjGJyQX9xq/Fo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734381993; h=from:from:reply-to: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=Zf3j+7x8OWqZs5Flqu4Qd02MEQlkGNkjLaHkJZbmiPk=; b=rWCymyrtoEBRhsmkHgTRbBBmhwNwhZpD3ySnhk2LHZEYzKRKfsvB/tbEvpMHwLQpU+6Kp5 XvGXsau6GEOVkhAw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734381993; h=from:from:reply-to: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=Zf3j+7x8OWqZs5Flqu4Qd02MEQlkGNkjLaHkJZbmiPk=; b=Fq8ab15zLwMJeAcPPchg2JxEmVpMu7TNStBTYe+WK7joiuL2w08lSnO6e2fT8N0aYgUN3w S6r+Z0G+a+zvcqQVKfd71OYRQeKEWh+0XbBYmJ6gY/qXl40vYAp2ktK3J32eAkONhNYKiS nwjqmjiCXPjqFIE46zgjGJyQX9xq/Fo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734381993; h=from:from:reply-to: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=Zf3j+7x8OWqZs5Flqu4Qd02MEQlkGNkjLaHkJZbmiPk=; b=rWCymyrtoEBRhsmkHgTRbBBmhwNwhZpD3ySnhk2LHZEYzKRKfsvB/tbEvpMHwLQpU+6Kp5 XvGXsau6GEOVkhAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DB406137CF; Mon, 16 Dec 2024 20:46:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id v8rsKqiRYGfiZAAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:32 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 3/9] io_uring/futex: Allocate ifd with generic alloc_cache helper Date: Mon, 16 Dec 2024 15:46:09 -0500 Message-ID: <20241216204615.759089-4-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -5.30 X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Level: Instead of open-coding the allocation, use the generic alloc_cache helper. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/futex.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/io_uring/futex.c b/io_uring/futex.c index e29662f039e1..30139cc150f2 100644 --- a/io_uring/futex.c +++ b/io_uring/futex.c @@ -251,17 +251,6 @@ static void io_futex_wake_fn(struct wake_q_head *wake_q, struct futex_q *q) io_req_task_work_add(req); } -static struct io_futex_data *io_alloc_ifd(struct io_ring_ctx *ctx) -{ - struct io_futex_data *ifd; - - ifd = io_alloc_cache_get(&ctx->futex_cache); - if (ifd) - return ifd; - - return kmalloc(sizeof(struct io_futex_data), GFP_NOWAIT); -} - int io_futexv_wait(struct io_kiocb *req, unsigned int issue_flags) { struct io_futex *iof = io_kiocb_to_cmd(req, struct io_futex); @@ -331,7 +320,7 @@ int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags) } io_ring_submit_lock(ctx, issue_flags); - ifd = io_alloc_ifd(ctx); + ifd = io_cache_alloc(&ctx->futex_cache, GFP_NOWAIT, NULL); if (!ifd) { ret = -ENOMEM; goto done_unlock; From patchwork Mon Dec 16 20:46:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910519 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6271C1D5CD7 for ; Mon, 16 Dec 2024 20:46:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734381997; cv=none; b=X0OLtI1g2ma6T6ihltlWWRJ/1YShCRq/bmZ3qW0dTg7aB8DNd7LKeEUdy8xnLdFIK8wKjqfRys9sb3yqezmh8C/1H0h+x3KlORd4z8v0GlaKNslUtHRDQ5lXdsKaOeYrsigejUUaUfA8YReydsMvukxAj05gfdgJn4CpLbzTNgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734381997; c=relaxed/simple; bh=xGkMWaPS2znrD/WhJrBKlRpXK6N5nUuaOnCu686nGYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nkEsgiSwg+J0KSAnkXhRBo3V2wdJwALXWHwSMM9BqLhDx4uPHr+scuszVxVFJ+q/Xmil0T0qdG2iPF/pdTJxJwsHFvbFiSQLwJnEXjz2BFlhhhvu8XWba2e4++DBs0j906gECtIm73IQ457/CJz0FMsB1n5woSDaZMvFejLCyVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DE26421120; Mon, 16 Dec 2024 20:46:34 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9B350137CF; Mon, 16 Dec 2024 20:46:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0TKMH6qRYGfmZAAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:34 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 4/9] io_uring/poll: Allocate apoll with generic alloc_cache helper Date: Mon, 16 Dec 2024 15:46:10 -0500 Message-ID: <20241216204615.759089-5-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Level: X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[] X-Spam-Score: -4.00 X-Spam-Flag: NO X-Rspamd-Queue-Id: DE26421120 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org This abstracts away the cache details to simplify the code. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/poll.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/io_uring/poll.c b/io_uring/poll.c index bced9edd5233..cc01c40b43d3 100644 --- a/io_uring/poll.c +++ b/io_uring/poll.c @@ -648,15 +648,12 @@ static struct async_poll *io_req_alloc_apoll(struct io_kiocb *req, if (req->flags & REQ_F_POLLED) { apoll = req->apoll; kfree(apoll->double_poll); - } else if (!(issue_flags & IO_URING_F_UNLOCKED)) { - apoll = io_alloc_cache_get(&ctx->apoll_cache); - if (!apoll) - goto alloc_apoll; - apoll->poll.retries = APOLL_MAX_RETRY; } else { -alloc_apoll: - apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC); - if (unlikely(!apoll)) + if (!(issue_flags & IO_URING_F_UNLOCKED)) + apoll = io_cache_alloc(&ctx->apoll_cache, GFP_ATOMIC, NULL); + else + apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC); + if (!apoll) return NULL; apoll->poll.retries = APOLL_MAX_RETRY; } From patchwork Mon Dec 16 20:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910520 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E1B31DD0F2 for ; Mon, 16 Dec 2024 20:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382003; cv=none; b=EjUJVP3RB3trkNI1auv38gcAkD5DxskhQKYiMsq1q1WKdad+t4NOkT/Br1kjzAEMrp48vB4WCgkfxvckl9+2ZN5IMwerbRtyBowHBQ6u0aDbA4nJjnur+kVzTa7p8sqORMzgRu4uw8eKafBzWnC+uFcrfr0kreVggHWWoOBJc50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382003; c=relaxed/simple; bh=L/A43CpJRy2ai6bk6igGg6mnkrnpONKOHzS/zl3VWk8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lJZfBk7Ad96UvYDF6Rs7TdwNtyz7AOxeQlykTrjq5SarCS9qZgYkVAkdZBIE0buO7sruEwgsMBYi7r4aLOLJPkyyK4q+DXksDFTCbPtaFWiWQA8lsBjyPZUlb0p6NgdBhpMJZicpkjfa/2+3uzVPxHMuX5Eq6iteSQrsR3cUg5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 930B81F37E; Mon, 16 Dec 2024 20:46:40 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3D993137CF; Mon, 16 Dec 2024 20:46:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id RC+4CLCRYGf3ZAAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:40 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 5/9] io_uring/uring_cmd: Allocate async data through generic helper Date: Mon, 16 Dec 2024 15:46:11 -0500 Message-ID: <20241216204615.759089-6-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Level: X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[] X-Spam-Score: -4.00 X-Spam-Flag: NO X-Rspamd-Queue-Id: 930B81F37E X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org This abstracts away the cache details and simplify the code. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/io_uring.h | 1 + io_uring/uring_cmd.c | 20 ++------------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index cd7bf71574e4..e43e9194dd0a 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -8,6 +8,7 @@ #include #include #include +#include "alloc_cache.h" #include "io-wq.h" #include "slist.h" #include "filetable.h" diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index af842e9b4eb9..d6ff803dbbe1 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -16,22 +16,6 @@ #include "rsrc.h" #include "uring_cmd.h" -static struct uring_cache *io_uring_async_get(struct io_kiocb *req) -{ - struct io_ring_ctx *ctx = req->ctx; - struct uring_cache *cache; - - cache = io_alloc_cache_get(&ctx->uring_cache); - if (cache) { - req->flags |= REQ_F_ASYNC_DATA; - req->async_data = cache; - return cache; - } - if (!io_alloc_async_data(req)) - return req->async_data; - return NULL; -} - static void io_req_uring_cleanup(struct io_kiocb *req, unsigned int issue_flags) { struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); @@ -185,8 +169,8 @@ static int io_uring_cmd_prep_setup(struct io_kiocb *req, struct io_uring_cmd *ioucmd = io_kiocb_to_cmd(req, struct io_uring_cmd); struct uring_cache *cache; - cache = io_uring_async_get(req); - if (unlikely(!cache)) + cache = io_uring_alloc_async_data(&req->ctx->uring_cache, req, NULL); + if (!cache) return -ENOMEM; if (!(req->flags & REQ_F_FORCE_ASYNC)) { From patchwork Mon Dec 16 20:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910521 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02366175BF for ; Mon, 16 Dec 2024 20:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382005; cv=none; b=QG2LfOxRoFBi7JYII7w+E0YLgspyIBaxnMorHdi2BhhgU96mhkHnlWVidPFYHGcYcerhj2Jv6PqAb5ZOcXydpnaTvov59NZOcvBR3F3CrMIUDb5ur4l4VFc74i01jo1ChZetk6Xd0pAO9s8tNAeeM52OycPPZnT7+SsImFomI3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382005; c=relaxed/simple; bh=o3XWb+ztFT4nsPWZIrjZBjjgOz24AeHFlG1kxx8yMMU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U/S4o/l+uoPTcbylEv16k86idMob46bVgB1p1Yum/C6J1ZQvqZ/EH9to5EhEegwhoOIpT8l9G04OPnTfdbirCFM9s20iS2mQZAZyMjAamd7hc6YWuwpgHK5k/wObWt1PNmYxcwl/S5CjNHD1YEhHyafw+pYAxVUW1EL221920vY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 53EC92111F; Mon, 16 Dec 2024 20:46:42 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 038A0137CF; Mon, 16 Dec 2024 20:46:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Y23yMbGRYGf5ZAAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:41 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 6/9] io_uring/net: Allocate msghdr async data through helper Date: Mon, 16 Dec 2024 15:46:12 -0500 Message-ID: <20241216204615.759089-7-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[] X-Spam-Flag: NO X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 53EC92111F X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: This abstracts away the cache details. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/net.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/io_uring/net.c b/io_uring/net.c index df1f7dc6f1c8..8457408194e7 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -155,30 +155,31 @@ static void io_netmsg_recycle(struct io_kiocb *req, unsigned int issue_flags) } } +static void io_msg_async_data_init(void *obj) +{ + struct io_async_msghdr *hdr = (struct io_async_msghdr *)obj; + + hdr->free_iov = NULL; + hdr->free_iov_nr = 0; +} + static struct io_async_msghdr *io_msg_alloc_async(struct io_kiocb *req) { struct io_ring_ctx *ctx = req->ctx; struct io_async_msghdr *hdr; - hdr = io_alloc_cache_get(&ctx->netmsg_cache); - if (hdr) { - if (hdr->free_iov) { - kasan_mempool_unpoison_object(hdr->free_iov, - hdr->free_iov_nr * sizeof(struct iovec)); - req->flags |= REQ_F_NEED_CLEANUP; - } - req->flags |= REQ_F_ASYNC_DATA; - req->async_data = hdr; - return hdr; - } + hdr = io_uring_alloc_async_data(&ctx->netmsg_cache, req, + io_msg_async_data_init); + if (!hdr) + return NULL; - if (!io_alloc_async_data(req)) { - hdr = req->async_data; - hdr->free_iov_nr = 0; - hdr->free_iov = NULL; - return hdr; + /* If the async data was cached, we might have an iov cached inside. */ + if (hdr->free_iov) { + kasan_mempool_unpoison_object(hdr->free_iov, + hdr->free_iov_nr * sizeof(struct iovec)); + req->flags |= REQ_F_NEED_CLEANUP; } - return NULL; + return hdr; } /* assign new iovec to kmsg, if we need to */ From patchwork Mon Dec 16 20:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910522 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E77B1DDC07 for ; Mon, 16 Dec 2024 20:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382008; cv=none; b=QphqeCbnukq7BZ2deE3HEUo+3Sz52HtIesaQH9bZ+6m7H0qe/op/BdCJhH15MQZyWYwMK+5CI46eFQePsGvI4RMiz4Wvd+po9/WGch6YmEVD2s0BZPqU3/IRqy8St3D+FXKvu11WkIrLUszefkS8EvjPc3A/tbWfvGF17AUpnBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382008; c=relaxed/simple; bh=3nULw4xyKngF3OssTsavNb+GJVZWUqjbedLz9oxLqFU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uwxQVpWSR6X6t29BjLuNWEyMVC+wqXVUSwuuqWgUzXQ/mmVaJJDZpBFHhYFgQaCfDDByC6tdHtRqnrr/O1mdNH4/tCKQNyV90g5lzKU1blksMYrLMB1/AyiNy78DlRkyNaBtFVF1D8Vez6+3ed+4958RS6H5lvrccWsWtIl1M+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 91E501F37E; Mon, 16 Dec 2024 20:46:44 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 414AF137CF; Mon, 16 Dec 2024 20:46:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mZzwArSRYGf9ZAAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:44 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 7/9] io_uring/rw: Allocate async data through helper Date: Mon, 16 Dec 2024 15:46:13 -0500 Message-ID: <20241216204615.759089-8-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[] X-Spam-Flag: NO X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 91E501F37E X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: This abstract away the cache details. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/rw.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/io_uring/rw.c b/io_uring/rw.c index 5b24fd8b69f6..bdfc3faef85d 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -208,33 +208,29 @@ static void io_req_rw_cleanup(struct io_kiocb *req, unsigned int issue_flags) } } +static void io_rw_async_data_init(void *obj) +{ + struct io_async_rw *rw = (struct io_async_rw *)obj; + + rw->free_iovec = 0; + rw->bytes_done = 0; +} + static int io_rw_alloc_async(struct io_kiocb *req) { struct io_ring_ctx *ctx = req->ctx; struct io_async_rw *rw; - rw = io_alloc_cache_get(&ctx->rw_cache); - if (rw) { - if (rw->free_iovec) { - kasan_mempool_unpoison_object(rw->free_iovec, - rw->free_iov_nr * sizeof(struct iovec)); - req->flags |= REQ_F_NEED_CLEANUP; - } - req->flags |= REQ_F_ASYNC_DATA; - req->async_data = rw; - goto done; - } - - if (!io_alloc_async_data(req)) { - rw = req->async_data; - rw->free_iovec = NULL; - rw->free_iov_nr = 0; -done: + rw = io_uring_alloc_async_data(&ctx->rw_cache, req, io_rw_async_data_init); + if (!rw) + return -ENOMEM; + if (rw->free_iovec) { + kasan_mempool_unpoison_object(rw->free_iovec, + rw->free_iov_nr * sizeof(struct iovec)); + req->flags |= REQ_F_NEED_CLEANUP; rw->bytes_done = 0; - return 0; } - - return -ENOMEM; + return 0; } static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import) From patchwork Mon Dec 16 20:46:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910523 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BFD6175BF for ; Mon, 16 Dec 2024 20:46:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382017; cv=none; b=WvTvZs2z+wdUbsKvgjknttRHUMhTNq/qkJGBPgKFnrv2e5kIvnZHBKa1E9BM9aNJYTmQhDLf/0Dy2yEjAx4cNKOG/utsHR4rhXU7fFOPLcbYb4EmAmFJ+alJdGOuOByQ4LgekzAREz6lrbMexjTqPVY4AZidW/3l2OoQDHgmokU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382017; c=relaxed/simple; bh=wzcPNTearvL23esFLZrvk0GL5LtF7FQ0AuP3SDkoqt8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TcOki3VYef74NXS4jutKsKIzg8pyoNJU8L1+RuvaLzUejbe+ALfwTb1t3G6oVv2/Cja9ew58Wi4MODSANLzL3QkDsCC1nMKDEq8xm8K3XR0K/uPR9Odf6xUlXQGD4Jm4CdGX6NmlMu9wm/zI4naKBtG0SonmjzuDQDtvqIm/nlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=BbBtUWJw; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=BKihP6LO; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=BbBtUWJw; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=BKihP6LO; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BbBtUWJw"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="BKihP6LO"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BbBtUWJw"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="BKihP6LO" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4F1992111F; Mon, 16 Dec 2024 20:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734382014; h=from:from:reply-to: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=LChTt1bCaXhqCjHmHPyn9J5d31DczI1zw8IsfSwq6hc=; b=BbBtUWJwW1zBVgBVx4WVpsgHQ8RDghZYUi4PW/olPrGAD5mZQ3NdxxMRwgZv15NVGfvUmh 7TKgl7irRoV2ST3Vv2nlvMftWPLPchdsDe9CxWltyUnz6aszA5u92vjwig9op+pweRxvBZ bckCzeX/1M6H8D5RDP8ZAftlJ2Q1hwI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734382014; h=from:from:reply-to: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=LChTt1bCaXhqCjHmHPyn9J5d31DczI1zw8IsfSwq6hc=; b=BKihP6LO9KgZESjD5BjxygvqG5/1rbglGXWQIiiYx8Vf7R7ETOyAt2V4ri3ZBrah79P3Cv i5EefGe0gNq/3eBQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734382014; h=from:from:reply-to: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=LChTt1bCaXhqCjHmHPyn9J5d31DczI1zw8IsfSwq6hc=; b=BbBtUWJwW1zBVgBVx4WVpsgHQ8RDghZYUi4PW/olPrGAD5mZQ3NdxxMRwgZv15NVGfvUmh 7TKgl7irRoV2ST3Vv2nlvMftWPLPchdsDe9CxWltyUnz6aszA5u92vjwig9op+pweRxvBZ bckCzeX/1M6H8D5RDP8ZAftlJ2Q1hwI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734382014; h=from:from:reply-to: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=LChTt1bCaXhqCjHmHPyn9J5d31DczI1zw8IsfSwq6hc=; b=BKihP6LO9KgZESjD5BjxygvqG5/1rbglGXWQIiiYx8Vf7R7ETOyAt2V4ri3ZBrah79P3Cv i5EefGe0gNq/3eBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 13A35137CF; Mon, 16 Dec 2024 20:46:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id azolOr2RYGcEZQAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:53 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 8/9] io_uring: Move old async data allocation helper to header Date: Mon, 16 Dec 2024 15:46:14 -0500 Message-ID: <20241216204615.759089-9-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -5.30 X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TAGGED_RCPT(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Level: There are two remaining uses of the old async data allocator that do not rely on the alloc cache. I don't want to make them use the new allocator helper because that would require a if(cache) check, which will result in dead code for the cached case (for callers passing a cache, gcc can't prove the cache isn't NULL, and will therefore preserve the check. Since this is an inline function and just a few lines long, keep a second helper to deal with cases where we don't have an async data cache. No functional change intended here. This is just moving the helper around and making it inline. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/io_uring.c | 13 ------------- io_uring/io_uring.h | 12 ++++++++++++ io_uring/timeout.c | 5 ++--- io_uring/waitid.c | 4 ++-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index ae36aa702f46..e34a4af54e6b 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1639,19 +1639,6 @@ io_req_flags_t io_file_get_flags(struct file *file) return res; } -bool io_alloc_async_data(struct io_kiocb *req) -{ - const struct io_issue_def *def = &io_issue_defs[req->opcode]; - - WARN_ON_ONCE(!def->async_size); - req->async_data = kmalloc(def->async_size, GFP_KERNEL); - if (req->async_data) { - req->flags |= REQ_F_ASYNC_DATA; - return false; - } - return true; -} - static u32 io_get_sequence(struct io_kiocb *req) { u32 seq = req->ctx->cached_sq_head; diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index e43e9194dd0a..032758b28d78 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -12,6 +12,7 @@ #include "io-wq.h" #include "slist.h" #include "filetable.h" +#include "opdef.h" #ifndef CREATE_TRACE_POINTS #include @@ -233,6 +234,17 @@ static inline void *io_uring_alloc_async_data(struct io_alloc_cache *cache, return req->async_data; } +static inline void *io_uring_alloc_async_data_nocache(struct io_kiocb *req) +{ + const struct io_issue_def *def = &io_issue_defs[req->opcode]; + + WARN_ON_ONCE(!def->async_size); + req->async_data = kmalloc(def->async_size, GFP_KERNEL); + if (req->async_data) + req->flags |= REQ_F_ASYNC_DATA; + return req->async_data; +} + static inline bool req_has_async_data(struct io_kiocb *req) { return req->flags & REQ_F_ASYNC_DATA; diff --git a/io_uring/timeout.c b/io_uring/timeout.c index f3d502717aeb..f55e25338b23 100644 --- a/io_uring/timeout.c +++ b/io_uring/timeout.c @@ -525,10 +525,9 @@ static int __io_timeout_prep(struct io_kiocb *req, if (WARN_ON_ONCE(req_has_async_data(req))) return -EFAULT; - if (io_alloc_async_data(req)) + data = io_uring_alloc_async_data_nocache(req); + if (!data) return -ENOMEM; - - data = req->async_data; data->req = req; data->flags = flags; diff --git a/io_uring/waitid.c b/io_uring/waitid.c index daef5dd644f0..6778c0ee76c4 100644 --- a/io_uring/waitid.c +++ b/io_uring/waitid.c @@ -303,10 +303,10 @@ int io_waitid(struct io_kiocb *req, unsigned int issue_flags) struct io_waitid_async *iwa; int ret; - if (io_alloc_async_data(req)) + iwa = io_uring_alloc_async_data_nocache(req); + if (!iwa) return -ENOMEM; - iwa = req->async_data; iwa->req = req; ret = kernel_waitid_prepare(&iwa->wo, iw->which, iw->upid, &iw->info, From patchwork Mon Dec 16 20:46:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13910524 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95DA01DDA10 for ; Mon, 16 Dec 2024 20:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382019; cv=none; b=AnEJsDx+lla8sLQ4mqqccW/IBLgWkK/zvUhRhNVvoezFBLaUvZR1s69ur2fpYdsDuGveIEhU9wpgSzeMM2X0nKg7Ft0pV6KqspzHUu0aNgOfTVldU02eqF81Y8ikK2+oFX1RwRR1QuVQAxWALPWwPhfwkbB9WclwkePvuMydUZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734382019; c=relaxed/simple; bh=T5ZoPB4jTWtkbjxlS0b+n+6kPmQ9I5vGUofva+V6WTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IMao4WmCUz6/QewQHkpUhQxSmWiol26EF1xg0zP4xCM+vtFjyjlx5zovDdiZGQpp0kk9xGL7oifipnqrUAtVd79wO76Z6YhQkhKxSgZEWH9xFM5uVkTRqXSjAbWVcdv/adL9mczvuTqtAC0HDM+/99WrMnhK5q7eIeK8ZHuUvNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 243F01F37E; Mon, 16 Dec 2024 20:46:56 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E1764137CF; Mon, 16 Dec 2024 20:46:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 65wDMb+RYGcOZQAAD6G6ig (envelope-from ); Mon, 16 Dec 2024 20:46:55 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH RESEND v2 9/9] io_uring/msg_ring: Drop custom destructor Date: Mon, 16 Dec 2024 15:46:15 -0500 Message-ID: <20241216204615.759089-10-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241216204615.759089-1-krisman@suse.de> References: <20241216204615.759089-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[] X-Spam-Flag: NO X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 243F01F37E X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: kfree can handle slab objects nowadays. Drop the extra callback and just use kfree. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/io_uring.c | 4 ++-- io_uring/msg_ring.c | 7 ------- io_uring/msg_ring.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index e34a4af54e6b..5535a72b0ce1 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -361,7 +361,7 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p) io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free); io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free); io_alloc_cache_free(&ctx->uring_cache, kfree); - io_alloc_cache_free(&ctx->msg_cache, io_msg_cache_free); + io_alloc_cache_free(&ctx->msg_cache, kfree); io_futex_cache_free(ctx); kvfree(ctx->cancel_table.hbs); xa_destroy(&ctx->io_bl_xa); @@ -2692,7 +2692,7 @@ static __cold void io_ring_ctx_free(struct io_ring_ctx *ctx) io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free); io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free); io_alloc_cache_free(&ctx->uring_cache, kfree); - io_alloc_cache_free(&ctx->msg_cache, io_msg_cache_free); + io_alloc_cache_free(&ctx->msg_cache, kfree); io_futex_cache_free(ctx); io_destroy_buffers(ctx); io_free_region(ctx, &ctx->param_region); diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c index 333c220d322a..bd3cd78d2dba 100644 --- a/io_uring/msg_ring.c +++ b/io_uring/msg_ring.c @@ -354,10 +354,3 @@ int io_uring_sync_msg_ring(struct io_uring_sqe *sqe) return __io_msg_ring_data(fd_file(f)->private_data, &io_msg, IO_URING_F_UNLOCKED); } - -void io_msg_cache_free(const void *entry) -{ - struct io_kiocb *req = (struct io_kiocb *) entry; - - kmem_cache_free(req_cachep, req); -} diff --git a/io_uring/msg_ring.h b/io_uring/msg_ring.h index 38e7f8f0c944..32236d2fb778 100644 --- a/io_uring/msg_ring.h +++ b/io_uring/msg_ring.h @@ -4,4 +4,3 @@ int io_uring_sync_msg_ring(struct io_uring_sqe *sqe); int io_msg_ring_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags); void io_msg_ring_cleanup(struct io_kiocb *req); -void io_msg_cache_free(const void *entry);