From patchwork Fri Nov 22 21:15:33 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: 13883640 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 A6505175D25 for ; Fri, 22 Nov 2024 21:15: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=1732310157; cv=none; b=UkL0usyce8WYrookgEtNq3hexpUqCEBohFfRCOCved0EwhEnxHrUnjo1QNLss19ehZlwRK72kXAS4i9IQh1cY1zjQRg6h+aGpDxA8sbh3nBpTn4zlO6awlA7BEnwzVIMv2GvC9f6xeCL+O9GQxdgHfuSWstXjIRXgM5T3bFt7+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310157; c=relaxed/simple; bh=BBaMLGHJfK2NjRYV4grWKBmxae8Q/AOnhL16FkoD8tI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cjRzcxBPPad6HOtLGYy3rWKinZRXNdDsyFxLtLFiPncE6QQFE9UJTgcv3D+OR69PKpUeJzfwWjGoZ5qrPypT0FL2wT/mi6znw9bHG0dDwf6RI5hjIXnKDJ5NNVCmUCUKGNN6ziuDGOK+2p96adKN9BshonMTUNXKWTsefzHHv0M= 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=AqWRKetO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=11dN+SOJ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=AqWRKetO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=11dN+SOJ; 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="AqWRKetO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="11dN+SOJ"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="AqWRKetO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="11dN+SOJ" 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 D55AC211FF; Fri, 22 Nov 2024 21:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310153; 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=AqWRKetOf44rKHmilScnlg9aaxmkOXKl1KxbS69g8xkjQ0wraI7Kjmt8057NhMBmsXeNsZ hsoXZfOuTeMTpfPCtaQhl179bFAuykBiSdS92fiY4DNK0Ml1Ovz2Ihf0KpOi0PubL0VCey RNqU51wcLllalJpU+GRWHiSdgg2etCc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310153; 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=11dN+SOJvZxO1K4W0PPDMXJWL+K7UibzbDJN/OKlGNRcetGYIXhkrOWeVISFdHo7JHe+CD 1VwUIKEEtAHFAfAQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310153; 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=AqWRKetOf44rKHmilScnlg9aaxmkOXKl1KxbS69g8xkjQ0wraI7Kjmt8057NhMBmsXeNsZ hsoXZfOuTeMTpfPCtaQhl179bFAuykBiSdS92fiY4DNK0Ml1Ovz2Ihf0KpOi0PubL0VCey RNqU51wcLllalJpU+GRWHiSdgg2etCc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310153; 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=11dN+SOJvZxO1K4W0PPDMXJWL+K7UibzbDJN/OKlGNRcetGYIXhkrOWeVISFdHo7JHe+CD 1VwUIKEEtAHFAfAQ== 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 9DED013998; Fri, 22 Nov 2024 21:15: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 84WMIIn0QGe7XQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:15: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 v2 1/9] io_uring: Fold allocation into alloc_cache helper Date: Fri, 22 Nov 2024 16:15:33 -0500 Message-ID: <20241122211541.2135280-2-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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 [-1.30 / 50.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]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -1.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 Fri Nov 22 21:15:34 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: 13883643 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 B4FDD156F3A for ; Fri, 22 Nov 2024 21:16:03 +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=1732310166; cv=none; b=AcYcBN6QNov6I6Cf5oXVTgyLCimgwpiRGAgCLmgdbPRp68Al8UGMcBQSdYp5YIRwlkogEN8bE7dc79w4H4phRr2GvejSaEwydc9BvQSuynPrTA+Tt7lJGWdCgiduozSPeHV9egS0InXEAX6TE2WQ4IUhv3q4J7Q0s7U7qN2dwwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310166; c=relaxed/simple; bh=ZKECSKQZAEy2tYVHbXFG+qadlwUv4Do3BePvhPWuxTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F+/jiIBIwnkrJyL+Yz0HGgeYd2MxqZ7lsP05EdIgPDmOcQjbQdpAXzTHXephhkuhzT9Y6aUc8G3PkrY1OEfoYh7/sq/l3nGbn4d7nZx2cgXJkHG7DhrkDVvp8gd5cemqab89m4NiM86LGepYv+0QFk+xH+ENHJwhCYOhNNC9Aa0= 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=a0VreOH+; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=x7Bb38Ct; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=a0VreOH+; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=x7Bb38Ct; 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="a0VreOH+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="x7Bb38Ct"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="a0VreOH+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="x7Bb38Ct" 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 96A7D1F79B; Fri, 22 Nov 2024 21:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310155; 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=UceOIPobMJtRBzOKOUv4mPDrqLxt37UEBcXu5ghGuzE=; b=a0VreOH+fUseOqWDYn4EfivG9G0vZiHDeBD3Rp7Ekf2pyEmRcmiidaL3X435DtNP5fS/i9 2KbAefJZo1RkT6ihH37G2fIc9W+w2g2Cg4TduRUwEcLubk+hWARldDLVEBhf8Yc+z3QjEg QAN0s2/xFqe9ZNMsNPhZhRdvNOG63QQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310155; 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=UceOIPobMJtRBzOKOUv4mPDrqLxt37UEBcXu5ghGuzE=; b=x7Bb38CtP9XEBFhYr28ATk8jGpBB7i7gTuyOCaU+uvUANFc/X+0XpzT1Pch6w804W8CKCo I5c9QqTSzMYZb4Cg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=a0VreOH+; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=x7Bb38Ct DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310155; 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=UceOIPobMJtRBzOKOUv4mPDrqLxt37UEBcXu5ghGuzE=; b=a0VreOH+fUseOqWDYn4EfivG9G0vZiHDeBD3Rp7Ekf2pyEmRcmiidaL3X435DtNP5fS/i9 2KbAefJZo1RkT6ihH37G2fIc9W+w2g2Cg4TduRUwEcLubk+hWARldDLVEBhf8Yc+z3QjEg QAN0s2/xFqe9ZNMsNPhZhRdvNOG63QQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310155; 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=UceOIPobMJtRBzOKOUv4mPDrqLxt37UEBcXu5ghGuzE=; b=x7Bb38CtP9XEBFhYr28ATk8jGpBB7i7gTuyOCaU+uvUANFc/X+0XpzT1Pch6w804W8CKCo I5c9QqTSzMYZb4Cg== 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 5F5DD13998; Fri, 22 Nov 2024 21:15: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 QWFDEYv0QGfCXQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:15: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 v2 2/9] io_uring: Add generic helper to allocate async data Date: Fri, 22 Nov 2024 16:15:34 -0500 Message-ID: <20241122211541.2135280-3-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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-Queue-Id: 96A7D1F79B X-Spam-Score: -1.51 X-Rspamd-Action: no action X-Spamd-Result: default: False [-1.51 / 50.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)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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 4070d4c8ef97..ddf3f05c3622 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 Fri Nov 22 21:15:35 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: 13883644 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 AAF0317DFFC for ; Fri, 22 Nov 2024 21:16:04 +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=1732310166; cv=none; b=El+/DMbAHFMgucWGR1RE6MGMm5Zr20NgKmexBJBhqfDdY9CTRjSHFJL3RolVXTMBQGwRRoaGk4rl5ftSIJapuEhVxTm787F1z+ETMCQqa4Gt9C6h1xADscm36Ybwm+lJ3BQeKKNbD3ha4l3V8ZXvyTCfrzWQ8h7BxNsH/+xSSi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310166; c=relaxed/simple; bh=kFBkDnSnEZZ1VfI5FksgAvdRIAP5QPxLBN+/Yu2XlRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tTE05z6GPa+fZ8HO+srtbdTojTSxa5gNEBaRAAO6H7UR0q0V0xJ/g5oNrjEasJs736yGdHk1TasfxbKtM/yfNSZMurI7lZ+M3XtN/V9ER1Xcyj9zWpbh6FcJi3lSDl/CpgVIQWkFoswcH/Qo6ZC9X/EnptJ8ShUtbusTZPuO3qo= 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=URZrMc3E; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=aFEJS3ZD; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=URZrMc3E; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=aFEJS3ZD; 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="URZrMc3E"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="aFEJS3ZD"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="URZrMc3E"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="aFEJS3ZD" 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 55B8A1F79C; Fri, 22 Nov 2024 21:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310157; 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=URZrMc3E2Lkz/omXk+lJpHt32vjgvdhwPWQ4k43/QNAWx6l7zPuw9ns7gWKdVXOaWtVoIr +07ju8eFiT4+oIWh6Butnv2kiu1w/32bH8D7mZ6Q0D081Vyg7Svhh5QEkqZcuVQU3Fb6FJ cJWdCJtKamPvRqzEfuG3rYtRNzlrbOI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310157; 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=aFEJS3ZDHbS4EV4Dn4vfL3z+LW88h8OFl/z4KcyQa3BniAzrWGCEfe6U+NmGe1Nry9JGPB NOjMAegprulVhhBw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=URZrMc3E; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=aFEJS3ZD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310157; 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=URZrMc3E2Lkz/omXk+lJpHt32vjgvdhwPWQ4k43/QNAWx6l7zPuw9ns7gWKdVXOaWtVoIr +07ju8eFiT4+oIWh6Butnv2kiu1w/32bH8D7mZ6Q0D081Vyg7Svhh5QEkqZcuVQU3Fb6FJ cJWdCJtKamPvRqzEfuG3rYtRNzlrbOI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310157; 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=aFEJS3ZDHbS4EV4Dn4vfL3z+LW88h8OFl/z4KcyQa3BniAzrWGCEfe6U+NmGe1Nry9JGPB NOjMAegprulVhhBw== 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 1D0BA13998; Fri, 22 Nov 2024 21:15:56 +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 qfEmN4z0QGfFXQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:15:56 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 3/9] io_uring/futex: Allocate ifd with generic alloc_cache helper Date: Fri, 22 Nov 2024 16:15:35 -0500 Message-ID: <20241122211541.2135280-4-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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-Queue-Id: 55B8A1F79C X-Spam-Level: X-Spamd-Result: default: False [-1.51 / 50.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)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim,suse.de:mid]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -1.51 X-Spam-Flag: NO 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 Fri Nov 22 21:15:36 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: 13883642 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 B55F4156F3A for ; Fri, 22 Nov 2024 21:16:00 +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=1732310162; cv=none; b=Dm6JC4BqsWg4luv9IM2VBiVTswCurUrU/mv86XNhK5KQm35Gro8mhP5MBezUD5wXobbubtrirZHTNHTXdVB0IWlNXcIQHxyvmB436r8uHnSqyQlWmEG3AlnoF/StdPIwt+WGsmqukJsNIY93vrL+mkODMRuCdY9A53fYaSWJieM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310162; c=relaxed/simple; bh=xGkMWaPS2znrD/WhJrBKlRpXK6N5nUuaOnCu686nGYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lnecNQ80tb2SjJ9j6/5ev2xZ97CNoxT0EBfcoyH5zznbfgZHSyX/y+TQ0Frik0aF2c2+Rj8Lk6uZwuYU5EytWhnWEEEyQSvo6K01mxkPp4whS3LC1ubjvKPk0npsatp2a1bgCcdH4rCSEaPFcTCSrmrgjabQrOvCtyNepwR+D/A= 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=a4YOZm7f; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UvhGFgxm; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=vPgIIcFO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=496owy0m; 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="a4YOZm7f"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UvhGFgxm"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="vPgIIcFO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="496owy0m" 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 EF00B1F79D; Fri, 22 Nov 2024 21:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310159; 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=bl+PVWrEKuoCakgEOxNrvLrDO3Ka7iUD9t77N791eO0=; b=a4YOZm7fx0ZqrsVHrPT+1Jz3oKLfWqCTdlAIUWb9oF4MdReWSefE9KZ8lprIzNJzZcvYgN jzOqXFC3CLZq49uzk81G69JOQVV2yjhTFNT6RONcfgF/jCDTWkZ/MVQQleeGkQc0ZJ6zWW u+SLPoAyxvIpn/xjOdw8kZsp5MkPCSU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310159; 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=bl+PVWrEKuoCakgEOxNrvLrDO3Ka7iUD9t77N791eO0=; b=UvhGFgxmnAWeHEqwBv77TgNpbEDyqxiZ36H6ft3jr+h8iSwGOkwD0Pg98Fr0K36Iw8kgSe eg4HlzFYpd2Wp5BA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310158; 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=bl+PVWrEKuoCakgEOxNrvLrDO3Ka7iUD9t77N791eO0=; b=vPgIIcFODfT0DnFHhDhvDBacV4jyCUkUoKO4OP8FJ7/D/HFbJWQHlx4ODqTT8H6t/Fvtbk qYWk7YFmUl9t7MJiAN0f+6xZ+TXa0QWTPXThDGuoQRCgKMWEaCfjHxOwJlakKj23Ys1XDm mAh/8+qqdcjQqdb8+LYkwJgfkBkw8I0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310158; 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=bl+PVWrEKuoCakgEOxNrvLrDO3Ka7iUD9t77N791eO0=; b=496owy0mUycKjohDQ3cPtRme9Afe8DhcTFz9IKQOI4TOgz13N/dcMc+tk+S99xaRT7gVz9 N4vHAlhplJfe3/Dw== 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 B463113998; Fri, 22 Nov 2024 21:15:58 +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 zWbtJY70QGfIXQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:15:58 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 4/9] io_uring/poll: Allocate apoll with generic alloc_cache helper Date: Fri, 22 Nov 2024 16:15:36 -0500 Message-ID: <20241122211541.2135280-5-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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: -1.30 X-Spamd-Result: default: False [-1.30 / 50.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]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Level: 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 Fri Nov 22 21:15:37 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: 13883645 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 B0572189B8A for ; Fri, 22 Nov 2024 21:16:02 +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=1732310167; cv=none; b=jjsAuqo4lH/Mo7HoGZZdQ+MnR0kMtjWcDMKbG/i+Yt/HDRn2RazsLEJKc4vH9IDSUMJw2fyDM6McTzs8Nrky4kizbhpzmgc4/ch0chSDXLji5dnNXe+6rqrsRy/YTI+bqW8E64b6wNU9qdwiff1wvThNfSynwtuCpTSQ08Yqxq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310167; c=relaxed/simple; bh=5WoqjSwwUE9bU5sKV+4i9+RapnGP/RtMwaSLAWVCV2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=anO3pVQxz+WdtKwg61SENQWUdoBgiukY4adV6HCvu3vUsVNA8x1qnNMkL4cjORxTvl4pYni0Z8oxHDoG1dtvEy8ckn9XXVnyqgCC1RB4Lc/YRR79Jp/Sisl+mhp4/xZ5515EFZuqL3ggF9l2LSqukXyTx4Zb416NXDPiSclm12g= 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=YgviElC2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=TFTa+bwB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=YgviElC2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=TFTa+bwB; 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="YgviElC2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="TFTa+bwB"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="YgviElC2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="TFTa+bwB" 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 094D41F79E; Fri, 22 Nov 2024 21:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310161; 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=ZVyY8rJDbIZ67Po5mOsXYAGukUb3YTyduqCEDWLu3co=; b=YgviElC2GCDI8+nusDgI/Q1g0eQDq0WTEtQWsP4+aR4emBa6nIQLq3bs3oc41tBkBEYk9K 9AvhaLeVh/qE3i6ZFcd/FqpsDGoclfT3eE9LkuL8bIR5IC0LNhlIRa6tXoQSL/Z1RxBT16 6Qq+J9ZT+AGIyqUmBQgno6oA6JO+Tmw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310161; 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=ZVyY8rJDbIZ67Po5mOsXYAGukUb3YTyduqCEDWLu3co=; b=TFTa+bwBXJ5gjc/DGIdSNTfhS5pbnEfA/Wov0zW5sOkKMcFKqpyfYsj7gcXAd0jUXSZcfK gUsZWbpqomwMGtDQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310161; 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=ZVyY8rJDbIZ67Po5mOsXYAGukUb3YTyduqCEDWLu3co=; b=YgviElC2GCDI8+nusDgI/Q1g0eQDq0WTEtQWsP4+aR4emBa6nIQLq3bs3oc41tBkBEYk9K 9AvhaLeVh/qE3i6ZFcd/FqpsDGoclfT3eE9LkuL8bIR5IC0LNhlIRa6tXoQSL/Z1RxBT16 6Qq+J9ZT+AGIyqUmBQgno6oA6JO+Tmw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310161; 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=ZVyY8rJDbIZ67Po5mOsXYAGukUb3YTyduqCEDWLu3co=; b=TFTa+bwBXJ5gjc/DGIdSNTfhS5pbnEfA/Wov0zW5sOkKMcFKqpyfYsj7gcXAd0jUXSZcfK gUsZWbpqomwMGtDQ== 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 BA6AA13998; Fri, 22 Nov 2024 21:16:00 +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 h1xJJZD0QGfMXQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:16:00 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 5/9] io_uring/uring_cmd: Allocate async data through generic helper Date: Fri, 22 Nov 2024 16:15:37 -0500 Message-ID: <20241122211541.2135280-6-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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 [-1.30 / 50.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]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -1.30 X-Spam-Flag: NO 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 ddf3f05c3622..91414a4da1b2 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 e9d99d3ecc34..8c1c732b3f15 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); @@ -181,8 +165,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 Fri Nov 22 21:15:38 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: 13883646 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 A83B254F95 for ; Fri, 22 Nov 2024 21:16:10 +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=1732310172; cv=none; b=dzUR4bdc3G+rvqR60s9q8j209ju5kfMrm4TNTaH5Sp5Lr33ALjMtkDI1VDUka7yzEFVI0LEMBnCVGBjqpmJj3h4+R41mHZZpZf+Vbi/bn4nHcieHJdYeGtVTCHlVrWPU3+VNTC2lsjauSfNHWPQw65GRZnUEt4yma6yJarGRsD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310172; c=relaxed/simple; bh=o3XWb+ztFT4nsPWZIrjZBjjgOz24AeHFlG1kxx8yMMU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VmV6dvmbqIfE7fOSW5llZ+fbtXUJ00MvUw/B1NH4wV1HvjEpdvYhcNOXfEteqoqWbb81o+lb+b0jzc+0oItPWogW5HscMzC0Ez0rAi1WL/ggKcJOttAq91Y4Ap+IE2wStLPa/iciN1rzoNd0C8oqgo71MaA5dqihLDVygVpavOA= 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=ya5lK9Vn; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=EG1WY9Te; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=A1xonI0Z; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=+mY64JaK; 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="ya5lK9Vn"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="EG1WY9Te"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="A1xonI0Z"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+mY64JaK" 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 AD01021200; Fri, 22 Nov 2024 21:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310168; 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=i37RvDHe3b/txmys4XbZFO1wo8mNN+93QYUjCHcPtm4=; b=ya5lK9VnxONYmIWbIpTnZlEOKnFBMMIpnHl4SD9T8F9kSwjou1GEBO4zNzOcZqnukwgshq P45Hr6S7DQ4QJLfbyARhtp3XonZhBY11DlrxBL7HUhyrYlfxNknaRfQ+e1+J+1iJfl3oFb WxbcMpYwoDTmB+Yxc52+0Cad5xHuOyE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310168; 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=i37RvDHe3b/txmys4XbZFO1wo8mNN+93QYUjCHcPtm4=; b=EG1WY9TeGx4mvAATYuDA7lVuYb2xwha6DUB3ABsptxXoVWoPmMZ2Ewdn9NYI/y/9a9wMLU K3VyNs6ZyOiZrDDg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310167; 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=i37RvDHe3b/txmys4XbZFO1wo8mNN+93QYUjCHcPtm4=; b=A1xonI0ZodNh9fUDhFKK3BcJ0jFbTQn79MC6OBa2XMxTNEa5p+jr1RgbbgdY+tskh8COhY 2Nc7nvf5tVMAK5MO6K1MJd663+36JLKegInTaiSMwRSVL37kg14N1tBflHkTVA7jfuHq1U djdkolQfKVl6tZHjhATaveuh74aVPG0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310167; 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=i37RvDHe3b/txmys4XbZFO1wo8mNN+93QYUjCHcPtm4=; b=+mY64JaKHwzbL0h5mFfnkPTaySry2aQ3+XhWOAnVWAVDwF6ZcqNBul4nMx1htZXpTqY4FA ATskhwKMYNoNqjBQ== 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 71ABA13998; Fri, 22 Nov 2024 21:16:07 +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 3fWhFZf0QGfTXQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:16:07 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 6/9] io_uring/net: Allocate msghdr async data through helper Date: Fri, 22 Nov 2024 16:15:38 -0500 Message-ID: <20241122211541.2135280-7-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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 [-1.30 / 50.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]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -1.30 X-Spam-Flag: NO 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 Fri Nov 22 21:15:39 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: 13883647 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 5A68C175D25 for ; Fri, 22 Nov 2024 21:16:12 +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=1732310173; cv=none; b=j/jspnioj/GvSvQs1b4P4jvi1pZ2+5acfrf/jpOlTtlFYUO4j85oK7EqHStrSXeUxO0VTFgSba3erQweUhpDM+VfrroGuOYoOFdaxV5xe+Mt8M5MYpxmE8huW4MBSUKbsuyXs85RMtqHm9WrSUdYcAMk1PBDkip5H8hESM9COos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310173; c=relaxed/simple; bh=USjvZpgabqKVE4L8ueOmg5x9CHE86v8DH9caKMaFsV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CFkenVXHBEG2BHKp+5UakHC7KjsO/TvFpqB8zXXtCA5Z6SyXylMEQjaZFNPbM0ah8lzFQAINi/LEBUMhO41pcbPWOfFqc9m6lcUObI1ZaVG2/W+7QwPAv5/MNeeRUIPFt2VPQws9Ii3yFqE8RUZlnHgTLJNziLx/MMHLqK7Tr5o= 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=U5aVAIOe; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=/Qw3cns8; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=qMt/lF1K; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=gi6Wd+cU; 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="U5aVAIOe"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/Qw3cns8"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qMt/lF1K"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="gi6Wd+cU" 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 D3EE41F79A; Fri, 22 Nov 2024 21:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310170; 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=DVMCZhA7JpbHKzYBjwLx6OI2Apsvr/ckMYSKmJ4Mqw8=; b=U5aVAIOe/NxvYy2Bw+NaWZymwUuiOGRLE2MMAazwZCkF8qGbynLHL/IQyqp2QtFKQAFmQ2 47YX2fY7+iOeVwH74Pd46/iCET69LxfVomUiZCWWFHUXqh986S94AHy2uXZg/X6qjzb0o/ uZNZuXB5yrZK9FPQixhlLHRXEPZHe6U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310170; 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=DVMCZhA7JpbHKzYBjwLx6OI2Apsvr/ckMYSKmJ4Mqw8=; b=/Qw3cns8UlG46Gx48tGqZaSPS8aH5zOL2ydoMilTaWhX/oODTdCqFwMp+tN0bgcZoDiCqQ LA6r5kBoLdNc/fBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="qMt/lF1K"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=gi6Wd+cU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310169; 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=DVMCZhA7JpbHKzYBjwLx6OI2Apsvr/ckMYSKmJ4Mqw8=; b=qMt/lF1Ke/sXq+EYu+avD6GBSOtD1Iwv9TjK7oiyaxj0EoQ4syAsfGRVc1D2vL76O5BWNY GopViFW3vmnnxUCUmpgV9pkHHdw4npRIhZ45IcbzwCXkVZkUI+HGOXNpE0yyR44t3q/bYY 5k7UJ5nKdTudx/+nnOrYw5J7hjiLIlM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310169; 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=DVMCZhA7JpbHKzYBjwLx6OI2Apsvr/ckMYSKmJ4Mqw8=; b=gi6Wd+cUpEsv+djvQDNVtZay2qr49v+js9ZM6FReojLDM6iJClgVs8DRW88BGCJJXUtbMM ewxagrcNxdi6NRCw== 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 81F9B13998; Fri, 22 Nov 2024 21:16:09 +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 l42PE5n0QGfXXQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:16:09 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 7/9] io_uring/rw: Allocate async data through helper Date: Fri, 22 Nov 2024 16:15:39 -0500 Message-ID: <20241122211541.2135280-8-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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-Queue-Id: D3EE41F79A X-Spam-Score: -1.51 X-Rspamd-Action: no action X-Spamd-Result: default: False [-1.51 / 50.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)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO 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 b62cdb5fc936..0db9259bcdd8 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 Fri Nov 22 21:15:40 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: 13883648 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 2AA40185935 for ; Fri, 22 Nov 2024 21:16:13 +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=1732310174; cv=none; b=bZxXoDqq/zZMg67WvtdIqKc+EZRFyYhdgBsal/za2dMy7rsXkT1+gwc57e9YE/cGCs7gSOeV5f9DhZPqmhF8iaaXWPAnSOMdBfG2KpISo+8whs1uQwEU52kLNaYMoRL/S8+olyMwek5V4fcuvMLgMfscRd3n5W5pvLpqwyTpSQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310174; c=relaxed/simple; bh=ug5qwzfDoq4jP8N+GgqelNZOEIYdlOPn+CA1KbzYS80=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vl/y2uz0BHd6418O/JPRrEp3DmbHleoqFnA2ievhPJ5q4bjfae57BTj+Egcdm8imAdkuZ/VNjkD6khiljLi1dOG31ps5yj5Yt5r2PyYNiChu+euykqQqTORFTMZXjendPm4QC0X8BGJLV2Ho8Q7Bc87qo3v5bPUY8ZqB5Ee2aVQ= 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=HSsdL44B; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=5Xsw2e/m; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=HSsdL44B; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=5Xsw2e/m; 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="HSsdL44B"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="5Xsw2e/m"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="HSsdL44B"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="5Xsw2e/m" 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 A4839211FF; Fri, 22 Nov 2024 21:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310171; 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=Fit5cB00P9J1ddoFuX578NEg8p69De2TjOOtiEvyYUI=; b=HSsdL44BJ5nRY2k1Ax5f/bzTW4rR0mnNFjPDSnZcfy6N+P+XVQO0RP4ZZaCM5EowzApX9V MwPf4O0bLVAyn0gvcla+w3BOabLrm4iufwb6bnzdw8pUxOc0Viti58aSxgqTFD4wx2fpWH 8gQaw+Hstc7bBSeJWXrL08Y8peJecdY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310171; 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=Fit5cB00P9J1ddoFuX578NEg8p69De2TjOOtiEvyYUI=; b=5Xsw2e/mGvUxAz0/B7PmeJgmAQ5Hj2lLzsFuXqHLNn4cyu1H9eqm+Fwvsei88db7/PyvG7 qb/ZZJBHskdn0WAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310171; 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=Fit5cB00P9J1ddoFuX578NEg8p69De2TjOOtiEvyYUI=; b=HSsdL44BJ5nRY2k1Ax5f/bzTW4rR0mnNFjPDSnZcfy6N+P+XVQO0RP4ZZaCM5EowzApX9V MwPf4O0bLVAyn0gvcla+w3BOabLrm4iufwb6bnzdw8pUxOc0Viti58aSxgqTFD4wx2fpWH 8gQaw+Hstc7bBSeJWXrL08Y8peJecdY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310171; 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=Fit5cB00P9J1ddoFuX578NEg8p69De2TjOOtiEvyYUI=; b=5Xsw2e/mGvUxAz0/B7PmeJgmAQ5Hj2lLzsFuXqHLNn4cyu1H9eqm+Fwvsei88db7/PyvG7 qb/ZZJBHskdn0WAg== 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 6CAAC13998; Fri, 22 Nov 2024 21:16:11 +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 +NSOFJv0QGfaXQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:16:11 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 8/9] io_uring: Move old async data allocation helper to header Date: Fri, 22 Nov 2024 16:15:40 -0500 Message-ID: <20241122211541.2135280-9-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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: -1.30 X-Spamd-Result: default: False [-1.30 / 50.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]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; 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 bd71782057de..08c42a0e3e74 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1616,19 +1616,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 91414a4da1b2..cbd2c0358bb1 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 5b12bd6a804c..078dfd6fcf71 100644 --- a/io_uring/timeout.c +++ b/io_uring/timeout.c @@ -526,10 +526,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 Fri Nov 22 21:15:41 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: 13883649 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 EFB96189909 for ; Fri, 22 Nov 2024 21:16:14 +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=1732310176; cv=none; b=eYcYAwpprL+e1J0OnBVyYLoMB524jWEC5wPDF4Wfgw2rpfKfzA0Mh6+j48V5KZXnj+XgyS5ZMvJanhHSZ8WjGHoMeQcG9B7jbVE4Z212SkXCAIfrNyd4HQ8XDMNwBJYJc2v0g2BHuNbyT/uV/BdSNHD4ZmvHRUhXnYUZXIVBg+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732310176; c=relaxed/simple; bh=Fgfw0rnRWuj34c7lmsjDmG4onhxt8XB673osQsaNJTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VY10Y3oTW7ocMEUHpDF8/ZA0Pue9zJwM3S992vSpAKuG8NF1J/2Qn6BUZHlLJAsvxv4xxI68edNmRA3lv571SFx0ixBJ2RaD0C6i5hy+W85nopLthKrQHy9XuTRXk9BxQgi9F8Pzy9BzmthOZFo/GwLQ6Lvroim7SW0Rrq4EUSw= 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=wO3Qla++; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=tJjkbJse; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=wO3Qla++; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=tJjkbJse; 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="wO3Qla++"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="tJjkbJse"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="wO3Qla++"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="tJjkbJse" 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 531EF21200; Fri, 22 Nov 2024 21:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310173; 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=ztVHk8HwhzP7hT8mRZgASJKgTI7AJFZ8CjPhxJFXT1w=; b=wO3Qla++zDzVMNqweFmahPzR8+QhPnHs7S67D7WGEt7UsGbnvUQAfnNqZbeczXNdjwC43r 6UlPPEFXLqqzwZAA/s1XEeKs88EDSYbqEsDb1xiZ7/z9AmwT++HYlRR8d9+cjAN8qZjkeI tk30DalcysQtDrNVgMZ20ScZPF109a8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310173; 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=ztVHk8HwhzP7hT8mRZgASJKgTI7AJFZ8CjPhxJFXT1w=; b=tJjkbJseHGLA6m2BLhcqqnvBpwx0BI/sO23XF5qEKUz8/f89b4YxK/gRM4/dWO03QkVmEt JLSvSwkc/qFVZABA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732310173; 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=ztVHk8HwhzP7hT8mRZgASJKgTI7AJFZ8CjPhxJFXT1w=; b=wO3Qla++zDzVMNqweFmahPzR8+QhPnHs7S67D7WGEt7UsGbnvUQAfnNqZbeczXNdjwC43r 6UlPPEFXLqqzwZAA/s1XEeKs88EDSYbqEsDb1xiZ7/z9AmwT++HYlRR8d9+cjAN8qZjkeI tk30DalcysQtDrNVgMZ20ScZPF109a8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732310173; 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=ztVHk8HwhzP7hT8mRZgASJKgTI7AJFZ8CjPhxJFXT1w=; b=tJjkbJseHGLA6m2BLhcqqnvBpwx0BI/sO23XF5qEKUz8/f89b4YxK/gRM4/dWO03QkVmEt JLSvSwkc/qFVZABA== 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 1C0EC13998; Fri, 22 Nov 2024 21:16:12 +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 q/riOJz0QGfcXQAAD6G6ig (envelope-from ); Fri, 22 Nov 2024 21:16:12 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk, asml.silence@gmail.com Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 9/9] io_uring/msg_ring: Drop custom destructor Date: Fri, 22 Nov 2024 16:15:41 -0500 Message-ID: <20241122211541.2135280-10-krisman@suse.de> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241122211541.2135280-1-krisman@suse.de> References: <20241122211541.2135280-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: -1.30 X-Spamd-Result: default: False [-1.30 / 50.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]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FREEMAIL_TO(0.00)[kernel.dk,gmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO 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 08c42a0e3e74..1e591234f32b 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); @@ -2693,7 +2693,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_unregister_cqwait_reg(ctx); diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c index e63af34004b7..d41ea29802a6 100644 --- a/io_uring/msg_ring.c +++ b/io_uring/msg_ring.c @@ -358,10 +358,3 @@ int io_uring_sync_msg_ring(struct io_uring_sqe *sqe) } return ret; } - -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);