From nobody Thu Apr 2 21:31:50 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8730AC6FA82 for ; Tue, 20 Sep 2022 17:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231309AbiITRfh (ORCPT ); Tue, 20 Sep 2022 13:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbiITRf3 (ORCPT ); Tue, 20 Sep 2022 13:35:29 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1796746D9F for ; Tue, 20 Sep 2022 10:35:27 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id lh5so7878950ejb.10 for ; Tue, 20 Sep 2022 10:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=q3ItRxAU/BxmLQ4LgAu2LZCds3bc6ZWDAT8CVSuBctA=; b=L7MGMS5Vt/CFqXHz2tNq5GjrmRDNs2FHaP3oHkoVigpYySA2PiuSES/U9tKioSrzBD LR/Yq4K8iTlbnaDydJMhUNVB1zElGo/lje8Zfg3RWnjwVIzh6RfQQgSYZMAgoA89JzEb I3QSpNmqSN3yeTdWaxbAYv1Q93MXaaXNEU+u0kYmRGSoSLvOoJqNqj4b4HHC3XUsR2Zb fWqcI3HCmQ/orbL3oshYY2hsyILX0234gLAO6peP+daaWTRUu8DZGliXyaSRRmU8VqTt WSESYc7m9Tnd1T73ycKa3KiTQIDKkO+9LdTKBm5GRoxk/aC7BfRQX87vKeay8vzkwIJR RXZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=q3ItRxAU/BxmLQ4LgAu2LZCds3bc6ZWDAT8CVSuBctA=; b=o0K6VV/Xy8DZnpn8mZ4p/9WyEg17n4S77NyFlVD7GoMTxSeXuppIFbYm0WEBw4ol0b qEgvIG/AIV9Lb+fPIWgaqwo17yvXCa/esTZEkOS1x0NHuC8nV5EMdJq/UJstBUfMR+Du Gj51k/tyFy5rdziG+ZyRp71brLTI0NrCZPltiqEpiRbgYV/GmFYMEjG93tFA7ckat3XW /WEXtS9qfHkLkMcBQO/4LAkvbwtAhbDkEvTozNfxFu9qBHpbmXulXcEPKAOw2YUDNqkZ 3MCehVELLYvpBo9ahZkBx4Pa+oDeHWbAMV/bKHrAACoBdXDE3r8VJ2ZiEBO2jw16754w 1lXg== X-Gm-Message-State: ACrzQf1UNZUZfBN7e9OijBdBNIpeOymSqjoDo8bXuT7yuo3J00IL3A71 0nU/5C+ZaYG7ZTAe3DFN6xgromCiIQ== X-Google-Smtp-Source: AMsMyM4rLL8K5sid/7uiFqINM4gT7UcvR6j8C8YClaQEY7G1y689ZNiNu39HIs3Cv9kd6PoOImgpWQ== X-Received: by 2002:a17:907:2cce:b0:77a:6958:5aaa with SMTP id hg14-20020a1709072cce00b0077a69585aaamr17505452ejc.245.1663695325547; Tue, 20 Sep 2022 10:35:25 -0700 (PDT) Received: from localhost.localdomain ([46.53.248.206]) by smtp.gmail.com with ESMTPSA id d24-20020a056402001800b004511957d075sm181960edu.80.2022.09.20.10.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 10:35:24 -0700 (PDT) Date: Tue, 20 Sep 2022 20:35:23 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] proc: mark more files as permanent Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Mark /proc/devices /proc/kpagecount /proc/kpageflags /proc/kpagecgroup /proc/loadavg /proc/meminfo /proc/softirqs /proc/uptime /proc/version as permanent /proc entries, saving alloc/free and some list/spinlock ops per use. These files are never removed by the kernel so it is OK to mark them. Signed-off-by: Alexey Dobriyan --- fs/proc/devices.c | 6 +++++- fs/proc/internal.h | 5 +++++ fs/proc/loadavg.c | 6 +++++- fs/proc/meminfo.c | 5 ++++- fs/proc/page.c | 3 +++ fs/proc/softirqs.c | 6 +++++- fs/proc/uptime.c | 6 +++++- fs/proc/version.c | 6 +++++- 8 files changed, 37 insertions(+), 6 deletions(-) --- a/fs/proc/devices.c +++ b/fs/proc/devices.c @@ -4,6 +4,7 @@ #include #include #include +#include "internal.h" =20 static int devinfo_show(struct seq_file *f, void *v) { @@ -54,7 +55,10 @@ static const struct seq_operations devinfo_ops =3D { =20 static int __init proc_devices_init(void) { - proc_create_seq("devices", 0, NULL, &devinfo_ops); + struct proc_dir_entry *pde; + + pde =3D proc_create_seq("devices", 0, NULL, &devinfo_ops); + pde_make_permanent(pde); return 0; } fs_initcall(proc_devices_init); --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -79,6 +79,11 @@ static inline bool pde_is_permanent(const struct proc_di= r_entry *pde) return pde->flags & PROC_ENTRY_PERMANENT; } =20 +static inline void pde_make_permanent(struct proc_dir_entry *pde) +{ + pde->flags |=3D PROC_ENTRY_PERMANENT; +} + extern struct kmem_cache *proc_dir_entry_cache; void pde_free(struct proc_dir_entry *pde); =20 --- a/fs/proc/loadavg.c +++ b/fs/proc/loadavg.c @@ -9,6 +9,7 @@ #include #include #include +#include "internal.h" =20 static int loadavg_proc_show(struct seq_file *m, void *v) { @@ -27,7 +28,10 @@ static int loadavg_proc_show(struct seq_file *m, void *v) =20 static int __init proc_loadavg_init(void) { - proc_create_single("loadavg", 0, NULL, loadavg_proc_show); + struct proc_dir_entry *pde; + + pde =3D proc_create_single("loadavg", 0, NULL, loadavg_proc_show); + pde_make_permanent(pde); return 0; } fs_initcall(proc_loadavg_init); --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -162,7 +162,10 @@ static int meminfo_proc_show(struct seq_file *m, void = *v) =20 static int __init proc_meminfo_init(void) { - proc_create_single("meminfo", 0, NULL, meminfo_proc_show); + struct proc_dir_entry *pde; + + pde =3D proc_create_single("meminfo", 0, NULL, meminfo_proc_show); + pde_make_permanent(pde); return 0; } fs_initcall(proc_meminfo_init); --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -91,6 +91,7 @@ static ssize_t kpagecount_read(struct file *file, char __= user *buf, } =20 static const struct proc_ops kpagecount_proc_ops =3D { + .proc_flags =3D PROC_ENTRY_PERMANENT, .proc_lseek =3D mem_lseek, .proc_read =3D kpagecount_read, }; @@ -268,6 +269,7 @@ static ssize_t kpageflags_read(struct file *file, char = __user *buf, } =20 static const struct proc_ops kpageflags_proc_ops =3D { + .proc_flags =3D PROC_ENTRY_PERMANENT, .proc_lseek =3D mem_lseek, .proc_read =3D kpageflags_read, }; @@ -322,6 +324,7 @@ static ssize_t kpagecgroup_read(struct file *file, char= __user *buf, } =20 static const struct proc_ops kpagecgroup_proc_ops =3D { + .proc_flags =3D PROC_ENTRY_PERMANENT, .proc_lseek =3D mem_lseek, .proc_read =3D kpagecgroup_read, }; --- a/fs/proc/softirqs.c +++ b/fs/proc/softirqs.c @@ -3,6 +3,7 @@ #include #include #include +#include "internal.h" =20 /* * /proc/softirqs ... display the number of softirqs @@ -27,7 +28,10 @@ static int show_softirqs(struct seq_file *p, void *v) =20 static int __init proc_softirqs_init(void) { - proc_create_single("softirqs", 0, NULL, show_softirqs); + struct proc_dir_entry *pde; + + pde =3D proc_create_single("softirqs", 0, NULL, show_softirqs); + pde_make_permanent(pde); return 0; } fs_initcall(proc_softirqs_init); --- a/fs/proc/uptime.c +++ b/fs/proc/uptime.c @@ -7,6 +7,7 @@ #include #include #include +#include "internal.h" =20 static int uptime_proc_show(struct seq_file *m, void *v) { @@ -39,7 +40,10 @@ static int uptime_proc_show(struct seq_file *m, void *v) =20 static int __init proc_uptime_init(void) { - proc_create_single("uptime", 0, NULL, uptime_proc_show); + struct proc_dir_entry *pde; + + pde =3D proc_create_single("uptime", 0, NULL, uptime_proc_show); + pde_make_permanent(pde); return 0; } fs_initcall(proc_uptime_init); --- a/fs/proc/version.c +++ b/fs/proc/version.c @@ -5,6 +5,7 @@ #include #include #include +#include "internal.h" =20 static int version_proc_show(struct seq_file *m, void *v) { @@ -17,7 +18,10 @@ static int version_proc_show(struct seq_file *m, void *v) =20 static int __init proc_version_init(void) { - proc_create_single("version", 0, NULL, version_proc_show); + struct proc_dir_entry *pde; + + pde =3D proc_create_single("version", 0, NULL, version_proc_show); + pde_make_permanent(pde); return 0; } fs_initcall(proc_version_init);