From patchwork Mon Jul 15 20:29:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13733872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B7D7C3DA59 for ; Mon, 15 Jul 2024 20:29:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A3276B00A8; Mon, 15 Jul 2024 16:29:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 401966B00AE; Mon, 15 Jul 2024 16:29:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D01C26B009B; Mon, 15 Jul 2024 16:29:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7835C6B00A0 for ; Mon, 15 Jul 2024 16:29:43 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2D9C6160234 for ; Mon, 15 Jul 2024 20:29:43 +0000 (UTC) X-FDA: 82343127846.30.1E2FD55 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf10.hostedemail.com (Postfix) with ESMTP id D84F9C0007 for ; Mon, 15 Jul 2024 20:29:40 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=prIKxLzt; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=aE2aSMpu; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=prIKxLzt; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=aE2aSMpu; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721075363; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yWewRUcOUAtVmN4JR7Gtyt2MolU1IAn0Ns4fcy6NIVg=; b=IH05l6sx6aIWPAEwjnnlSk5Ti4a7Y0U/BL/vxHxnrCubXSeoAbo73Yl/UG1Y0G0K/aYxHS BlA/eorOzrTWBf9Hs4PfzpNISvtT03DFNciNk6UO0MSQdF2n8fwOGkJshPwTwLYrFrltdY F3AVgk4lcG9V82G1iJ+hm3txWtlrHFs= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=prIKxLzt; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=aE2aSMpu; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=prIKxLzt; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=aE2aSMpu; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721075363; a=rsa-sha256; cv=none; b=fSdkTYDN30B4FeZeXBcoMTcSE+V9kb7Ayz0c9al0ukzZ6A7YlGkI/x1G5kx3I6Q/DMD+4Y 2chF49KhJcdCPSg0LIfbFrrC5l69nt7YZmeiH5CZdSVCnFOcJ9EI/F3c/vUxqEyL//1HWe 1TNbyKrzYx7llgH92jmZe1L3ErOwetw= 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 5119A21BD0; Mon, 15 Jul 2024 20:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1721075379; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yWewRUcOUAtVmN4JR7Gtyt2MolU1IAn0Ns4fcy6NIVg=; b=prIKxLztGfLbdeAhqgcoCK1H8//juWuOKqdI91X4l4EJajX8iU9dBgUIGHI3oTtT90n1En fQg+/C1t4mT5ErXDMfBha2YRuPoew0wPFfBnkeYyzXsLYW1WxkU/p8BRc1tUfOWDsSWGWn HpwOqvdETyGUnPP9tPNEBEpZKg2A9ro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1721075379; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yWewRUcOUAtVmN4JR7Gtyt2MolU1IAn0Ns4fcy6NIVg=; b=aE2aSMpuuGQWpz2WP9mQoUBD+DMuFoYlFRvPk5ajs9R0pwV7ByK+B24CBCTjYYCEhB3Ue/ /BDr04RNGcmpkdCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1721075379; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yWewRUcOUAtVmN4JR7Gtyt2MolU1IAn0Ns4fcy6NIVg=; b=prIKxLztGfLbdeAhqgcoCK1H8//juWuOKqdI91X4l4EJajX8iU9dBgUIGHI3oTtT90n1En fQg+/C1t4mT5ErXDMfBha2YRuPoew0wPFfBnkeYyzXsLYW1WxkU/p8BRc1tUfOWDsSWGWn HpwOqvdETyGUnPP9tPNEBEpZKg2A9ro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1721075379; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yWewRUcOUAtVmN4JR7Gtyt2MolU1IAn0Ns4fcy6NIVg=; b=aE2aSMpuuGQWpz2WP9mQoUBD+DMuFoYlFRvPk5ajs9R0pwV7ByK+B24CBCTjYYCEhB3Ue/ /BDr04RNGcmpkdCA== 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 31A361396E; Mon, 15 Jul 2024 20:29:39 +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 0NDVC7OGlWbvUwAAD6G6ig (envelope-from ); Mon, 15 Jul 2024 20:29:39 +0000 From: Vlastimil Babka Date: Mon, 15 Jul 2024 22:29:32 +0200 Subject: [PATCH RFC 6/6] kunit, slub: add test_kfree_rcu() MIME-Version: 1.0 Message-Id: <20240715-b4-slab-kfree_rcu-destroy-v1-6-46b2984c2205@suse.cz> References: <20240715-b4-slab-kfree_rcu-destroy-v1-0-46b2984c2205@suse.cz> In-Reply-To: <20240715-b4-slab-kfree_rcu-destroy-v1-0-46b2984c2205@suse.cz> To: "Paul E. McKenney" , Joel Fernandes , Josh Triplett , Boqun Feng , Christoph Lameter , David Rientjes Cc: Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Julia Lawall , Jakub Kicinski , "Jason A. Donenfeld" , "Uladzislau Rezki (Sony)" , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, Vlastimil Babka X-Mailer: b4 0.14.0 X-Rspamd-Action: no action X-Spamd-Bar: / X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D84F9C0007 X-Stat-Signature: zcd7jfgbe1qi63izw1fdz7tif1w55n8n X-HE-Tag: 1721075380-425625 X-HE-Meta: U2FsdGVkX1/sVxklxlc2kWjie7kcmipoirfGxWJKggbzlrK21LZ9GzkunHnfJGYh+ADuANcqhr4MorThV45h8RJolYcr9CODmPUMOX2e7uTNk0HnX7vSgWiW0+WciiuaWhdis2MWnY88aweDcmWHQYivbSjfwwiogpyHSGPwy9QQWGFAcFcZ75ZFcD7m6SW+T3bbvw/BUP53QGVTjOo0jCTB8VBqc4LOcTSjK7UOuDhaB2Jd529D5lpKwlPSSGwnKHE9LRuGZ+gookMA1JL9sYawHRk0Y+ciiaWukO88oR9JPt5zFTT8RPXhpq7Jem45pTJNIWvyfsu6qHDbFMFHfOq6GOYtNuAvHAUYCt+s87n5mDc/e4HLgyrN6TvFuIgsFqKNiYP6BVoDCwzQPSRbdoik8qNDUPef2C47dBijiE7LASM4f0xAz4IyUis5ycZo0tEWUXrztSw6aC9J29d2Kw7G4phXPfLdqoZk9RM/+fjXvWg8PF7aHFeVU1Y2its5qyVMq1x5OI20mK4HC/sa/nn+6rJmK/wcJlh3ZszGXofo6MLktaB+R4MOhoTrrxeSxlRgfilbrPPqNoKpds3r5tT4Hg19CShcWK/Rg2GqsI+HovYMeiB9h9WHF/gkYvYD4XlzE0mG9Yuls1gcHDZFFvhrLC4YfNTrHxC/Gh9I5Q1q1bkgrL5pNqRgNC7C0N9rZFEdmdXo9npAiRo68AnIA2FahKjNOxMGGhn05+LRNuQQD7d5PHYshk6Qz9mLy4Ezz0OaLWSkRQSuhYoYzuocjC+lluOLWPgWnXYF3SrPqV2vmrLnISkLfvbD3j2gm393fD2fuCY6p2okzpgkcYrw8FIIREoMKsWRSoVWhAOOdAhhBVC27QvSOeTABzKwKsTMdkZ0wydhpZY7u7psPWGqmLs9tEeAtlBVJES6/qKDXm6gxdbasry56coOR2759WM8SJeameE+PDK6rn4Ag9a zfWRRbYX 6JUGX1Xs1EZCUYkzkal9C3FjFLVz0qgfZOCaHpFeMgg+PPpT7XctUyYBwRxj/N2hm15pC6TrgSNPWj4UJdn/RcS1+0U+WbxkSqXFLYi/or9cBisTEGGxLpW63qTXq09yEqmLBtG27By8fKsIcKMdkz8Z1k/Ujq2GdhrIPJvH5r8Gg1gxtGS0lEjBpERB4tEuZ+Wc1MfCRfovlv4PsXVjKKa5cgPzM7jU0qM0goc97wJw2V9R/1uTbWQO/F5gJg+tcUW2mu/my6sbYmTSzNrtWfhQ1mWPeyjSYGdjkbOdUGsEIgdKmhAD7E/l7nv0lxBeJ8kF//ZIbrm0b8xmE0JXYAPJyb3q5znXX2l4K X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a test that will create cache, allocate one object, kfree_rcu() it and attempt to destroy it. If the asynchronous cache freeing works correctly, there should be no warnings in dmesg. Since the warnings in the failure case are produced by a work callback, I don't know if it's possible to capture it in the kunit test result properly. Signed-off-by: Vlastimil Babka --- lib/slub_kunit.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index e6667a28c014..e3e4d0ca40b7 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "../mm/slab.h" static struct kunit_resource resource; @@ -157,6 +158,26 @@ static void test_kmalloc_redzone_access(struct kunit *test) kmem_cache_destroy(s); } +struct test_kfree_rcu_struct { + struct rcu_head rcu; +}; + +static void test_kfree_rcu(struct kunit *test) +{ + struct kmem_cache *s = test_kmem_cache_create("TestSlub_kfree_rcu", + sizeof(struct test_kfree_rcu_struct), + SLAB_NO_MERGE); + struct test_kfree_rcu_struct *p = kmem_cache_alloc(s, GFP_KERNEL); + + kasan_disable_current(); + + KUNIT_EXPECT_EQ(test, 0, slab_errors); + + kasan_enable_current(); + kfree_rcu(p, rcu); + kmem_cache_destroy(s); +} + static int test_init(struct kunit *test) { slab_errors = 0; @@ -177,6 +198,7 @@ static struct kunit_case test_cases[] = { KUNIT_CASE(test_clobber_redzone_free), KUNIT_CASE(test_kmalloc_redzone_access), + KUNIT_CASE(test_kfree_rcu), {} };