From patchwork Tue Jun 20 14:44:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 110548 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3724556vqr; Tue, 20 Jun 2023 07:56:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51z568HLjw6XjMTjDxxBLeyBqysyF6tByJeNAENPDbDpMhJFbPx2h9vDw0KlyZDyRrUBzq X-Received: by 2002:a17:90a:f2d2:b0:25e:86ab:f4d7 with SMTP id gt18-20020a17090af2d200b0025e86abf4d7mr11743595pjb.22.1687273014319; Tue, 20 Jun 2023 07:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687273014; cv=none; d=google.com; s=arc-20160816; b=qKAvEklGuprGa90mSmolueI01H3Z1RhMGY/Tzhu5EEphH+WBdLcNes692HG30pskXu lMn6bcRPyW1Cu8v4iODlpdboCnPX4ROIRE4TJqLI9wClhCfAnY5MYIBmKWrR0oj1SHkB nt9dV4DvYDRkeMyBz3zIBGulnAP9w20OQrEvbYKxzuqliG1NAhOzeEw8wyTvrDQwyVqw 8xgZpqR08Yrf0rxLLQ6hhyOvPxoWAiYirlQ4Fs2OD8bZnzm+LSqKxuQMH/G+Kq79qxx3 Q7i7KeNwjfweVS6benHIgB+Me4YlFgNp+GLhRHlEPqsDxnD68kP94bjrZot50L6tLT3v TiGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WY2chNgunmkezs4ZsDoVnj+Gqfz2zU61Qap54PQ9+dc=; b=YGusk3xJQw+RG1mKjx9hfB8j/5jNBCtIP06xVltyqOBdvjIkkJ5RaA5Zl07zfi/lMV cukqOMVubPFCzXIQPnpeng5TL5DJhANWrleZOlIqwoyxzCPgLNRlQ/2ZFLbli1ZMP3gd 5Rbc4aUh2jlQeM+IAQn+3d7jsaJUwbCAAXkOg7n5GzV543giI+FAOett1OKc7ShOfV5W gmTGUi8Mk66D4uvZ6jZvMfZP/fnJiS183rotrlRsU0iZAGmq5MBAIjqUQn6zMCDHJ/yd uyAwMD6up6Z5JLxTNqNuNCZsnS+6z5RN5J6a9wCpXWI0q1JXFHLHJndM0dWugRrySMcu Fh2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MLwwgaMm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n31-20020a17090a5aa200b0025691c00096si1993908pji.140.2023.06.20.07.56.39; Tue, 20 Jun 2023 07:56:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MLwwgaMm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233331AbjFTOpQ (ORCPT + 99 others); Tue, 20 Jun 2023 10:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233390AbjFTOos (ORCPT ); Tue, 20 Jun 2023 10:44:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 782BC172C for ; Tue, 20 Jun 2023 07:44:44 -0700 (PDT) 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 C9FC1612DC for ; Tue, 20 Jun 2023 14:44:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2323C433C8; Tue, 20 Jun 2023 14:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687272283; bh=0M+nLDZFlAC5uRcRvEMx4cqFIB9rQ/EvGoomT6DUzoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MLwwgaMml5dK+FvsH6PsvtOiiQAoV4boR4i1tQlPEadC77P2+sXwbSxIp4PEiZIgP HSXE7vnBYJ9iviRTAL++jSv27eMNV+0lGziwRlGKEP86qj4a/Esh6lIClJelE/uZuv +tR910dysRtoUG5PHzjiugQN8txycfwTQpj9dffs= From: Greg Kroah-Hartman To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Ivan Orlov , Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Greg Kroah-Hartman Subject: [PATCH 3/3] x86/resctrl: make pseudo_lock_class a static const structure Date: Tue, 20 Jun 2023 16:44:34 +0200 Message-ID: <20230620144431.583290-6-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620144431.583290-4-gregkh@linuxfoundation.org> References: <20230620144431.583290-4-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3944; i=gregkh@linuxfoundation.org; h=from:subject; bh=ZrmDno1rLPLMmfgPHDkLl0x2OYPv6j0/RiEkxcIsOsI=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTd/uvrP4R+Pdra3ZSeXnI1OfTEsTVnjFV5hkEM8dub 84rtyzpiGVhEGRikBVTZPmyjefo/opDil6Gtqdh5rAygQxh4OIUgImcjWSYw7351gv3jes5d+1P 6PystCDmbO6OhQwLls9a8+Z240fe5VUcpnyzrBllF2yMBwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769233988361579859?= X-GMAIL-MSGID: =?utf-8?q?1769233988361579859?= From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the pseudo_lock_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Cc: Fenghua Yu Cc: Reinette Chatre Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: x86@kernel.org Cc: "H. Peter Anvin" Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman Acked-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 41 ++++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c index 458cb7419502..8f559eeae08e 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -45,7 +45,21 @@ static u64 prefetch_disable_bits; */ static unsigned int pseudo_lock_major; static unsigned long pseudo_lock_minor_avail = GENMASK(MINORBITS, 0); -static struct class *pseudo_lock_class; + +static char *pseudo_lock_devnode(const struct device *dev, umode_t *mode) +{ + const struct rdtgroup *rdtgrp; + + rdtgrp = dev_get_drvdata(dev); + if (mode) + *mode = 0600; + return kasprintf(GFP_KERNEL, "pseudo_lock/%s", rdtgrp->kn->name); +} + +static const struct class pseudo_lock_class = { + .name = "pseudo_lock", + .devnode = pseudo_lock_devnode, +}; /** * get_prefetch_disable_bits - prefetch disable bits of supported platforms @@ -1353,7 +1367,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp) &pseudo_measure_fops); } - dev = device_create(pseudo_lock_class, NULL, + dev = device_create(&pseudo_lock_class, NULL, MKDEV(pseudo_lock_major, new_minor), rdtgrp, "%s", rdtgrp->kn->name); @@ -1383,7 +1397,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp) goto out; out_device: - device_destroy(pseudo_lock_class, MKDEV(pseudo_lock_major, new_minor)); + device_destroy(&pseudo_lock_class, MKDEV(pseudo_lock_major, new_minor)); out_debugfs: debugfs_remove_recursive(plr->debugfs_dir); pseudo_lock_minor_release(new_minor); @@ -1424,7 +1438,7 @@ void rdtgroup_pseudo_lock_remove(struct rdtgroup *rdtgrp) pseudo_lock_cstates_relax(plr); debugfs_remove_recursive(rdtgrp->plr->debugfs_dir); - device_destroy(pseudo_lock_class, MKDEV(pseudo_lock_major, plr->minor)); + device_destroy(&pseudo_lock_class, MKDEV(pseudo_lock_major, plr->minor)); pseudo_lock_minor_release(plr->minor); free: @@ -1560,16 +1574,6 @@ static const struct file_operations pseudo_lock_dev_fops = { .mmap = pseudo_lock_dev_mmap, }; -static char *pseudo_lock_devnode(const struct device *dev, umode_t *mode) -{ - const struct rdtgroup *rdtgrp; - - rdtgrp = dev_get_drvdata(dev); - if (mode) - *mode = 0600; - return kasprintf(GFP_KERNEL, "pseudo_lock/%s", rdtgrp->kn->name); -} - int rdt_pseudo_lock_init(void) { int ret; @@ -1580,21 +1584,18 @@ int rdt_pseudo_lock_init(void) pseudo_lock_major = ret; - pseudo_lock_class = class_create("pseudo_lock"); - if (IS_ERR(pseudo_lock_class)) { - ret = PTR_ERR(pseudo_lock_class); + ret = class_register(&pseudo_lock_class); + if (ret) { unregister_chrdev(pseudo_lock_major, "pseudo_lock"); return ret; } - pseudo_lock_class->devnode = pseudo_lock_devnode; return 0; } void rdt_pseudo_lock_release(void) { - class_destroy(pseudo_lock_class); - pseudo_lock_class = NULL; + class_unregister(&pseudo_lock_class); unregister_chrdev(pseudo_lock_major, "pseudo_lock"); pseudo_lock_major = 0; }