All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Wang <li.wang@linux.dev>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] lib: Introduce tst_path.h to consolidate system paths
Date: Tue, 5 May 2026 11:04:38 +0800	[thread overview]
Message-ID: <aflePEoKwEB_oad6@linux.dev> (raw)
In-Reply-To: <afi3Ml5vFv2irnc0@yuki.lan>

Cyril Hrubis wrote:

> > @@ -25,8 +25,8 @@ static struct tst_test test = {
> >  	.setup = setup,
> >  	.save_restore = (const struct tst_path_val[]) {
> >  		{"/proc/nonexistent", NULL, TST_SR_SKIP},
> > -		{"/proc/sys/kernel/numa_balancing", NULL, TST_SR_TBROK},
> > -		{"/proc/sys/kernel/core_pattern", NULL, TST_SR_TCONF},
> > +		{PROC_SYS_KERNEL "numa_balancing", NULL, TST_SR_TBROK},
> > +		{PROC_SYS_KERNEL "core_pattern", NULL, TST_SR_TCONF},
> 
> This is exactly what I'm unsure about, it's not shorter, nor more
> readable.
> 
> Maybe if this was PATH_NUMA_BALANCING and PATH_CORE_PATTERN it would be
> shorter and would make much more sense.

v3-A version:

Yes, that ways would be simpler. Then we will finally get v3-A as below:

  /* KERNEL */
  #define PATH_HOSTNAME			"/proc/sys/kernel/hostname"
  #define PATH_OSRELEASE		"/proc/sys/kernel/osrelease"
  #define PATH_VERSION			"/proc/sys/kernel/version"
  #define PATH_DOMAINNAME		"/proc/sys/kernel/domainname"
  #define PATH_PRINTK			"/proc/sys/kernel/printk"
  #define PATH_PID_MAX			"/proc/sys/kernel/pid_max"
  #define PATH_SHMMAX			"/proc/sys/kernel/shmmax"
  #define PATH_SHMMNI			"/proc/sys/kernel/shmmni"
  #define PATH_SHMALL			"/proc/sys/kernel/shmall"
  #define PATH_MSGMNI			"/proc/sys/kernel/msgmni"
  #define PATH_SHM_NEXT_ID		"/proc/sys/kernel/shm_next_id"
  #define PATH_MSG_NEXT_ID		"/proc/sys/kernel/msg_next_id"
  #define PATH_SEM			"/proc/sys/kernel/sem"
  #define PATH_CORE_PATTERN		"/proc/sys/kernel/core_pattern"
  #define PATH_CAP_LAST_CAP		"/proc/sys/kernel/cap_last_cap"
  #define PATH_NUMA_BALANCING		"/proc/sys/kernel/numa_balancing"
  #define PATH_IO_URING_DISABLED	"/proc/sys/kernel/io_uring_disabled"
  #define PATH_OVERFLOWUID		"/proc/sys/kernel/overflowuid"
  #define PATH_OVERFLOWGID		"/proc/sys/kernel/overflowgid"
  #define PATH_PERF_EVENT_PARANOID	"/proc/sys/kernel/perf_event_paranoid"
  #define PATH_PERF_EVENT_MLOCK_KB	"/proc/sys/kernel/perf_event_mlock_kb"
  #define PATH_PERF_EVENT_MAX_SAMPLE_RATE	"/proc/sys/kernel/perf_event_max_sample_rate"
  #define PATH_SCHED_RT_PERIOD_US		"/proc/sys/kernel/sched_rt_period_us"
  #define PATH_SCHED_RT_RUNTIME_US	"/proc/sys/kernel/sched_rt_runtime_us"
  #define PATH_SCHED_RR_TIMESLICE_MS	"/proc/sys/kernel/sched_rr_timeslice_ms"
  #define PATH_UNPRIVILEGED_USERNS_CLONE	"/proc/sys/kernel/unprivileged_userns_clone"
  
  /* USER */
  #define PATH_MAX_USER_NAMESPACES	"/proc/sys/user/max_user_namespaces"
  
  /* FS */
  #define PATH_FS_PIPE_MAX_SIZE		"/proc/sys/fs/pipe-max-size"
  #define PATH_FS_PIPE_MAX_PAGES	"/proc/sys/fs/pipe-max-pages"
  
  /* VM */
  #define PATH_VM_NR_HPAGES		"/proc/sys/vm/nr_hugepages"
  #define PATH_VM_OVERCOMMIT_HPAGES	"/proc/sys/vm/nr_overcommit_hugepages"
  #define PATH_VM_DROP_CACHES		"/proc/sys/vm/drop_caches"
  #define PATH_VM_COMPACT_MEMORY	"/proc/sys/vm/compact_memory"
  #define PATH_VM_VFS_CACHE_PRESSURE	"/proc/sys/vm/vfs_cache_pressure"
  #define PATH_VM_OVERCOMMIT_MEMORY	"/proc/sys/vm/overcommit_memory"
  
  /* HUGETLB */
  #define PATH_MM_HUGEPAGES	"/sys/kernel/mm/hugepages/"
  #define PATH_MM_THP		"/sys/kernel/mm/transparent_hugepage/"
  
  /* KSM */
  #define PATH_MM_KSM		"/sys/kernel/mm/ksm/"
  #define MM_KSM_FP(s)		(PATH_MM_KSM s)
  
  /* NETWORK */
  #define PATH_NET_IPV4		"/proc/sys/net/ipv4/"
  #define NET_IPV4_FP(s)	(PATH_NET_IPV4 s)
  
  /* MEMINFO */
  #define MEMINFO_HPAGE_TOTAL	"HugePages_Total:"
  #define MEMINFO_HPAGE_FREE	"HugePages_Free:"
  #define MEMINFO_HPAGE_RSVD	"HugePages_Rsvd:"
  #define MEMINFO_HPAGE_SURP	"HugePages_Surp:"
  #define MEMINFO_HPAGE_SIZE	"Hugepagesize:"


> Shortening this to SYS_KERNEL("numa_balancing") would be confusing since
> we have both /proc/sys/ and /sys/

v3-B version:

After looking through all the LTP frequently used knobs (shown above),
I found that '/sys/kernel/' is not quite often used like '/proc/sys/kernel',
so basically we only need to handle the /proc one.

thus, maybe define PROC_KER_FP() or PROC_SYS_KERNEL_FP() instead of
list many KERNEL files in tst_path.h:

  /* KERNEL */
  #define PROC_KER_FP(s)		("/proc/sys/kernel/" s)
  
  /* USER */
  #define PROC_USER_FP(s)		("/proc/sys/user/" s)

  ...

In testcase used like:

  PROC_KER_FP("pid_max");
  PROC_KER_FP("shmmni");
  PROC_KER_FP("perf_event_mlock_kb");
  PROC_USER_FP("max_user_namespaces");


Which version (v3-A or v3-B) do you think is better?
Or any other suggestion?

-- 
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-05-05  3:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01 13:51 [LTP] [PATCH] lib: Introduce tst_path.h to consolidate system paths Li Wang
2026-05-04 13:30 ` [LTP] [PATCH v2] " Li Wang
2026-05-04 14:08   ` [LTP] " linuxtestproject.agent
2026-05-04 15:11   ` [LTP] [PATCH v2] " Cyril Hrubis
2026-05-05  3:04     ` Li Wang [this message]
2026-05-05  7:00       ` Cyril Hrubis
2026-05-05  7:13         ` Li Wang
2026-05-15 15:32     ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aflePEoKwEB_oad6@linux.dev \
    --to=li.wang@linux.dev \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.