From patchwork Tue Jun 20 18:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13286341 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 A89F4EB64D8 for ; Tue, 20 Jun 2023 18:33:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12CC18D0002; Tue, 20 Jun 2023 14:33:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DD278D0001; Tue, 20 Jun 2023 14:33:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0E1A8D0002; Tue, 20 Jun 2023 14:33:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E56E18D0001 for ; Tue, 20 Jun 2023 14:33:22 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C3CBF1A019A for ; Tue, 20 Jun 2023 18:33:22 +0000 (UTC) X-FDA: 80923973844.25.79FA400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id DABC140016 for ; Tue, 20 Jun 2023 18:33:19 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=chu0PrrF; spf=pass (imf04.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687286000; 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=Q+/yQ/hp+TTf72QRWqVaSTR6tKXRRAMjyCPC0ZpNfrk=; b=vYFA5ntx1mn/yrgzSKRIN63M7en07flFn6iEbYH/Yg/18X35BhLH+9GDiyrBmx9/PqdJqr hLItQLDCSQjA/wCXjPphppIqNIyH5J1kacUqnenb//qc2MxpwtPRaigAAVuI+BSpb8tJe0 1G4DnvOnLfyPLFPaHuJLPRr1PbTuF+g= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=chu0PrrF; spf=pass (imf04.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687286000; a=rsa-sha256; cv=none; b=TyZy72MrWEVhJeQfesOALrVp7bvjc5tRVjgtlr6Cfn/SMPamtGwUsSIQskK9zq/Rba0516 /RnKeqbxJR4Hpc3aRvoF/ycG59c7l7xS2hiOIkc9F6B6LaOz+CHduU3E2bv3h5/xOB1WjI AFKpuDwU1nSzPWpofWLjsE9bxjSLxL0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DB62061383; Tue, 20 Jun 2023 18:33:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1EC1C433C8; Tue, 20 Jun 2023 18:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687285998; bh=SqvhAodB465EsF7b1FR43lL1U65Vj+cZWCGrIetux8Y=; h=From:To:Cc:Subject:Date:From; b=chu0PrrFYy6l4aQH5YUrizUqIiYD5ldCLqo6p3KLUKCB3y9OH7OTLvMN2HFEd9QtI Q5t/2k4Knhg8mR9SBGuJtIi9QeslPAyiSm/vYJgzqfvV6uzfdUP7w/CCAz7wJVNH4I haHcyMwPEXYUcyKw3aWWCIxq33z/CymbhGiodCTE= From: Greg Kroah-Hartman To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Ivan Orlov , Andrew Morton , Greg Kroah-Hartman Subject: [PATCH] mm: backing-dev: make bdi_class a static const structure Date: Tue, 20 Jun 2023 20:33:15 +0200 Message-ID: <20230620183314.682822-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1837; i=gregkh@linuxfoundation.org; h=from:subject; bh=K0CQkPBo/+H1fLv6yQzfATV1NVqEuRkRSTLa+uZOhmc=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTP7zKtLnNftK6O6B49SrPd9OirXJfye8w0fhjYLXqx FF3B+3dHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRPY8Y5mfE3Hxy/ITP3dVT NtxxiN0b3pq0aQXD/NpZH1rF94j09Hdw3VuT/lPH/5ZmJwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Rspamd-Queue-Id: DABC140016 X-Rspam-User: X-Stat-Signature: z99bc86r81nsb45rc9oxw8k4acg6hrrb X-Rspamd-Server: rspam01 X-HE-Tag: 1687285999-932552 X-HE-Meta: U2FsdGVkX188bRSVkH0KnDpQWNVEmB5bdF+4GF6/RDDZacmTYKRwTP1XFZWipmqUbQnbXf7Vytkw4ajlp4JLQ4TSP1xSM1/vUdfxZvO8CYYHCZS92ROMG0j1L3xX+4xfX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iYoCTYC/cobaxzJP1wFbjHQEFX9VO2jLGR6uErVRW+1rb8jTUoqBfwcb/u9P9866YkhNwW8CtA6PDxTPkzIv4cmEfoQHH97uH3Dnfo7ZucqYMbH1gwSIRDhW/69GPXxiAV97komuk4jCzmdcPV8zvsYh3YSecbGQHwj0e+PCdp7nz3loEL254tm+VkOZmtBzwUWEAZz0Aa4LTVx6xU6g/5kJI5+MLv7MqDY1x2lcCQbfC8DYySH3/0Ls/qpwu7tYVT22B4jPUTtlzs3dDWN2c/0bQeTa03XFBMbHMCpEXzsDGFERigzGVrR6qYEjix53md7qygKx9zJdQ3c3AQfOk02dD9Rj4ZRfyxME2/cs4Ml3AfDQcQFBhFIlxFwngA0qcIEv9YZXyK71zjM6O0xZeedtvsI3dUZp2DHWxLltSsw= 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: From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the bdi_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at load time. Cc: Andrew Morton Cc: linux-mm@kvack.org Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- mm/backing-dev.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 7da9727fcdf3..3ffc3cfa7a14 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -20,7 +20,6 @@ struct backing_dev_info noop_backing_dev_info; EXPORT_SYMBOL_GPL(noop_backing_dev_info); -static struct class *bdi_class; static const char *bdi_unknown_name = "(unknown)"; /* @@ -345,13 +344,19 @@ static struct attribute *bdi_dev_attrs[] = { }; ATTRIBUTE_GROUPS(bdi_dev); +static const struct class bdi_class = { + .name = "bdi", + .dev_groups = bdi_dev_groups, +}; + static __init int bdi_class_init(void) { - bdi_class = class_create("bdi"); - if (IS_ERR(bdi_class)) - return PTR_ERR(bdi_class); + int ret; + + ret = class_register(&bdi_class); + if (ret) + return ret; - bdi_class->dev_groups = bdi_dev_groups; bdi_debug_init(); return 0; @@ -1001,7 +1006,7 @@ int bdi_register_va(struct backing_dev_info *bdi, const char *fmt, va_list args) return 0; vsnprintf(bdi->dev_name, sizeof(bdi->dev_name), fmt, args); - dev = device_create(bdi_class, NULL, MKDEV(0, 0), bdi, bdi->dev_name); + dev = device_create(&bdi_class, NULL, MKDEV(0, 0), bdi, bdi->dev_name); if (IS_ERR(dev)) return PTR_ERR(dev);