From patchwork Fri Sep 30 08:47:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 12995057 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 9815CC433F5 for ; Fri, 30 Sep 2022 08:47:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26FEB8D0005; Fri, 30 Sep 2022 04:47:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21FDF8D0001; Fri, 30 Sep 2022 04:47:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E9088D0005; Fri, 30 Sep 2022 04:47:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F417F8D0001 for ; Fri, 30 Sep 2022 04:47:47 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C64B7120755 for ; Fri, 30 Sep 2022 08:47:47 +0000 (UTC) X-FDA: 79968123774.30.5651A07 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by imf20.hostedemail.com (Postfix) with ESMTP id 2AB8B1C0016 for ; Fri, 30 Sep 2022 08:47:46 +0000 (UTC) Received: by mail-lj1-f171.google.com with SMTP id c7so4040428ljm.12 for ; Fri, 30 Sep 2022 01:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=9r3yesNDvHF4bI/ZQd/yVIvjI+ovfbKRt9UlHzDBDpo=; b=KfosB4NAN7pSi65zOuKl6MqdYNvxNGjMc5XHljAR+dfJackmXebe762Tjt48NOGNr/ DTmH17WfE2LpJm6IsKqLFIit9HGQseO8ewXWz78506AA67yDILD9peZde8RhU/BlrQTE iO4/R6MdoPLMaWOlJMD5R+9IDanymmQizVBA0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=9r3yesNDvHF4bI/ZQd/yVIvjI+ovfbKRt9UlHzDBDpo=; b=K9qjtFa+jRxX4VOZ1p6HhcLxRhQ3yVRMKISOxsUMLCTMn+zBwWpE+w9qaItKw2AX6T Y2LjYwGWS1GgJlJG7GERMgxuOz+EIll/fVQznUL/BotDprpNoBfqNPWvcGK7k22ZBRlE 9cxwzPGgDn9WllM22aTcdD9vMgK6uVzvkNT+iGtNFNcJN8WZ2IY7wHQ22Um7h59eAU6O Int0UDLa/8PZhnRXVhrjGjTced0zCyLEgfzDPdwet65u9gG007q16ftq/F2139eq8UZV v/E5SMV/QfdsOIUhdOw9vexfUdd59vrKJxHBw5/VH+zytMME/bx0rn7rcNbNvZSrY0cc WINg== X-Gm-Message-State: ACrzQf1ikISH8YueZC1218OeVuRIRdMhYx7sgcF1nDcnl0wOksEn/YOK Lf8uKhm0u3P2WaCJfFk09ZfJSg== X-Google-Smtp-Source: AMsMyM71wkHFcOEk79iv6oi8Ae75Va/dkrh2wttVeG5BtQiRnK39kt/pfONL87ULjT9ywBHtArQpiA== X-Received: by 2002:a2e:90da:0:b0:26c:8dc:3c52 with SMTP id o26-20020a2e90da000000b0026c08dc3c52mr2624000ljg.474.1664527665386; Fri, 30 Sep 2022 01:47:45 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id k21-20020a05651210d500b00494618889c0sm230691lfg.42.2022.09.30.01.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 01:47:44 -0700 (PDT) From: Rasmus Villemoes To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Rasmus Villemoes , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: slub: remove dead and buggy code from sysfs_slab_add() Date: Fri, 30 Sep 2022 10:47:42 +0200 Message-Id: <20220930084742.771804-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664527667; a=rsa-sha256; cv=none; b=TZfqNdTVyeYLnrpSjuxiIKDC3YzrvdNY+rLIaMFBDKc2+T/FkGaKcttvN68OTtu/eMHfq+ FPJ5VsH4c6zDbiQ0r/Jo/kEViKAQk2Bhz4ZUf8fU5iUeDFCgzFtwo9dOr/vlj6LnrV1iRE MLWkZtIJdXnFHCFtOBYhQNmUS5d7LSs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=rasmusvillemoes.dk header.s=google header.b=KfosB4NA; spf=pass (imf20.hostedemail.com: domain of linux@rasmusvillemoes.dk designates 209.85.208.171 as permitted sender) smtp.mailfrom=linux@rasmusvillemoes.dk; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664527667; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=9r3yesNDvHF4bI/ZQd/yVIvjI+ovfbKRt9UlHzDBDpo=; b=L7I8QUHJaztjDGHEfgyKNm/NGv1FSd5J8ULp/NDJGp/kydnqKrtGcSneYkhYmwX9plYCMm vsazJ0Ihgd0ViOeJJFWSjme3WVTllERZqcpCI77irHeExZEO67uM4z91eeHANbRi0NZ+lN jy++Ii/MIej0tx4TXdqLMphLqf0xMHM= X-Stat-Signature: o1moy75uk7bbj51g9zyp8wrjfxothreh X-Rspamd-Queue-Id: 2AB8B1C0016 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=rasmusvillemoes.dk header.s=google header.b=KfosB4NA; spf=pass (imf20.hostedemail.com: domain of linux@rasmusvillemoes.dk designates 209.85.208.171 as permitted sender) smtp.mailfrom=linux@rasmusvillemoes.dk; dmarc=none X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1664527666-937259 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: The function sysfs_slab_add() has two callers: One is slab_sysfs_init(), which first initializes slab_kset, and only when that succeeds sets slab_state to FULL, and then proceeds to call sysfs_slab_add() for all previously created slabs. The other is __kmem_cache_create(), but only after a if (slab_state <= UP) return 0; check. So in other words, sysfs_slab_add() is never called without slab_kset (aka the return value of cache_kset()) being non-NULL. And this is just as well, because if we ever did take this path and called kobject_init(&s->kobj), and then later when called again from slab_sysfs_init() would end up calling kobject_init_and_add(), we would hit if (kobj->state_initialized) { /* do not error out as sometimes we can recover */ pr_err("kobject (%p): tried to init an initialized object, something is seriously wrong.\n", dump_stack(); } in kobject.c. Signed-off-by: Rasmus Villemoes Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Acked-by: David Rientjes --- mm/slub.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 4b98dff9be8e..04a7f75a7b1f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5937,11 +5937,6 @@ static int sysfs_slab_add(struct kmem_cache *s) struct kset *kset = cache_kset(s); int unmergeable = slab_unmergeable(s); - if (!kset) { - kobject_init(&s->kobj, &slab_ktype); - return 0; - } - if (!unmergeable && disable_higher_order_debug && (slub_debug & DEBUG_METADATA_FLAGS)) unmergeable = 1;