* [RFC PATCH v2 0/4] remove duplicate ifdefs
@ 2024-01-22 17:49 Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 1/4] sched: " Shrikanth Hegde
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2024-01-22 17:49 UTC (permalink / raw)
To: linux-kernel, linux-ntfs-dev, linux-xfs, linuxppc-dev
Cc: sshegde, mpe, mingo, peterz, chandan.babu, anton, djwong
When going through the code observed a case in scheduler,
where #ifdef CONFIG_SMP was used to inside an #ifdef CONFIG_SMP.
That didn't make sense since first one is good enough and second
one is a duplicate.
This could improve code readability. No functional change is intended.
Since this might be present in other code areas wrote a very basic
python script which helps in finding these cases. It doesn't handle any
complicated #defines or space separated "# if". At some places the
log collected had to be manually corrected due to space separated ifdefs.
Thats why its not a treewide change.
There might be an opportunity for other files as well.
Logic is very simple. If there is #ifdef or #if or #ifndef add that
variable to list. Upon every subsequent #ifdef or #if or #ifndef
check if the same variable is in the list. If yes flag
an error. Verification was done manually later checking for any #undef
or any error due to script. These were the ones that flagged out and
made sense after going through code.
More details about how the logs were collected and the script used for
processing the logs are mentioned in v1 cover letter.
v2->v1:
split the fs change into two patches as suggested by Chandan Babu R.
v1: https://lore.kernel.org/all/20240118080326.13137-1-sshegde@linux.ibm.com/
Shrikanth Hegde (4):
sched: remove duplicate ifdefs
xfs: remove duplicate ifdefs
ntfs: remove duplicate ifdefs
arch/powerpc: remove duplicate ifdefs
arch/powerpc/include/asm/paca.h | 4 ----
arch/powerpc/kernel/asm-offsets.c | 2 --
arch/powerpc/platforms/powermac/feature.c | 2 --
arch/powerpc/xmon/xmon.c | 2 --
fs/ntfs/inode.c | 2 --
fs/xfs/xfs_sysfs.c | 4 ----
kernel/sched/core.c | 4 +---
kernel/sched/fair.c | 2 --
8 files changed, 1 insertion(+), 21 deletions(-)
--
2.39.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH v2 1/4] sched: remove duplicate ifdefs
2024-01-22 17:49 [RFC PATCH v2 0/4] remove duplicate ifdefs Shrikanth Hegde
@ 2024-01-22 17:49 ` Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 2/4] xfs: " Shrikanth Hegde
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2024-01-22 17:49 UTC (permalink / raw)
To: linux-kernel, linux-ntfs-dev, linux-xfs, linuxppc-dev
Cc: sshegde, mpe, mingo, peterz, chandan.babu, anton, djwong
when a ifdef is used in the below manner, second one could be considered as
duplicate.
ifdef DEFINE_A
...code block...
ifdef DEFINE_A
...code block...
endif
...code block...
endif
In the scheduler code, there are two places where above pattern can be
observed. Hence second ifdef is a duplicate and not needed.
Plus a minor comment update to reflect the else case.
No functional change is intended here. It only aims to improve code
readability.
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
kernel/sched/core.c | 4 +---
kernel/sched/fair.c | 2 --
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9116bcc90346..a76c7095f736 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1792,7 +1792,6 @@ static void cpu_util_update_eff(struct cgroup_subsys_state *css);
#endif
#ifdef CONFIG_SYSCTL
-#ifdef CONFIG_UCLAMP_TASK
#ifdef CONFIG_UCLAMP_TASK_GROUP
static void uclamp_update_root_tg(void)
{
@@ -1898,7 +1897,6 @@ static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
return result;
}
#endif
-#endif
static int uclamp_validate(struct task_struct *p,
const struct sched_attr *attr)
@@ -2065,7 +2063,7 @@ static void __init init_uclamp(void)
}
}
-#else /* CONFIG_UCLAMP_TASK */
+#else /* !CONFIG_UCLAMP_TASK */
static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p) { }
static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) { }
static inline int uclamp_validate(struct task_struct *p,
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 533547e3c90a..8e30e2bb77a0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10182,10 +10182,8 @@ static int idle_cpu_without(int cpu, struct task_struct *p)
* be computed and tested before calling idle_cpu_without().
*/
-#ifdef CONFIG_SMP
if (rq->ttwu_pending)
return 0;
-#endif
return 1;
}
--
2.39.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH v2 2/4] xfs: remove duplicate ifdefs
2024-01-22 17:49 [RFC PATCH v2 0/4] remove duplicate ifdefs Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 1/4] sched: " Shrikanth Hegde
@ 2024-01-22 17:49 ` Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 3/4] ntfs: " Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 4/4] arch/powerpc: " Shrikanth Hegde
3 siblings, 0 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2024-01-22 17:49 UTC (permalink / raw)
To: linux-kernel, linux-ntfs-dev, linux-xfs, linuxppc-dev
Cc: sshegde, mpe, mingo, peterz, chandan.babu, anton, djwong
when a ifdef is used in the below manner, second one could be considered as
duplicate.
ifdef DEFINE_A
...code block...
ifdef DEFINE_A
...code block...
endif
...code block...
endif
In the xfs code two such patterns were seen. Hence removing these ifdefs.
No functional change is intended here. It only aims to improve code
readability.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
fs/xfs/xfs_sysfs.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 17485666b672..d2391eec37fe 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -193,7 +193,6 @@ always_cow_show(
}
XFS_SYSFS_ATTR_RW(always_cow);
-#ifdef DEBUG
/*
* Override how many threads the parallel work queue is allowed to create.
* This has to be a debug-only global (instead of an errortag) because one of
@@ -260,7 +259,6 @@ larp_show(
return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.larp);
}
XFS_SYSFS_ATTR_RW(larp);
-#endif /* DEBUG */
STATIC ssize_t
bload_leaf_slack_store(
@@ -319,10 +317,8 @@ static struct attribute *xfs_dbg_attrs[] = {
ATTR_LIST(log_recovery_delay),
ATTR_LIST(mount_delay),
ATTR_LIST(always_cow),
-#ifdef DEBUG
ATTR_LIST(pwork_threads),
ATTR_LIST(larp),
-#endif
ATTR_LIST(bload_leaf_slack),
ATTR_LIST(bload_node_slack),
NULL,
--
2.39.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH v2 3/4] ntfs: remove duplicate ifdefs
2024-01-22 17:49 [RFC PATCH v2 0/4] remove duplicate ifdefs Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 1/4] sched: " Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 2/4] xfs: " Shrikanth Hegde
@ 2024-01-22 17:49 ` Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 4/4] arch/powerpc: " Shrikanth Hegde
3 siblings, 0 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2024-01-22 17:49 UTC (permalink / raw)
To: linux-kernel, linux-ntfs-dev, linux-xfs, linuxppc-dev
Cc: sshegde, mpe, mingo, peterz, chandan.babu, anton, djwong
when a ifdef is used in the below manner, second one could be considered as
duplicate.
ifdef DEFINE_A
...code block...
ifdef DEFINE_A
...code block...
endif
...code block...
endif
In the ntfs code, one such pattern was seen. Hence remove that duplicate
ifdef.
No functional change is intended here. It only aims to improve code
readability.
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
fs/ntfs/inode.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index aba1e22db4e9..d2c8622d53d1 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2859,11 +2859,9 @@ int ntfs_truncate(struct inode *vi)
*
* See ntfs_truncate() description above for details.
*/
-#ifdef NTFS_RW
void ntfs_truncate_vfs(struct inode *vi) {
ntfs_truncate(vi);
}
-#endif
/**
* ntfs_setattr - called from notify_change() when an attribute is being changed
--
2.39.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [RFC PATCH v2 4/4] arch/powerpc: remove duplicate ifdefs
2024-01-22 17:49 [RFC PATCH v2 0/4] remove duplicate ifdefs Shrikanth Hegde
` (2 preceding siblings ...)
2024-01-22 17:49 ` [RFC PATCH v2 3/4] ntfs: " Shrikanth Hegde
@ 2024-01-22 17:49 ` Shrikanth Hegde
3 siblings, 0 replies; 5+ messages in thread
From: Shrikanth Hegde @ 2024-01-22 17:49 UTC (permalink / raw)
To: linux-kernel, linux-ntfs-dev, linux-xfs, linuxppc-dev
Cc: sshegde, mpe, mingo, peterz, chandan.babu, anton, djwong
when a ifdef is used in the below manner, second one could be considered as
duplicate.
ifdef DEFINE_A
...code block...
ifdef DEFINE_A
...code block...
endif
...code block...
endif
few places in arch/powerpc where this pattern was seen. In addition to that
in paca.h, CONFIG_PPC_BOOK3S_64 was defined back to back. merged the two
ifdefs.
No functional change is intended here. It only aims to improve code
readability.
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
arch/powerpc/include/asm/paca.h | 4 ----
arch/powerpc/kernel/asm-offsets.c | 2 --
arch/powerpc/platforms/powermac/feature.c | 2 --
arch/powerpc/xmon/xmon.c | 2 --
4 files changed, 10 deletions(-)
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index e667d455ecb4..1d58da946739 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -163,9 +163,7 @@ struct paca_struct {
u64 kstack; /* Saved Kernel stack addr */
u64 saved_r1; /* r1 save for RTAS calls or PM or EE=0 */
u64 saved_msr; /* MSR saved here by enter_rtas */
-#ifdef CONFIG_PPC64
u64 exit_save_r1; /* Syscall/interrupt R1 save */
-#endif
#ifdef CONFIG_PPC_BOOK3E_64
u16 trap_save; /* Used when bad stack is encountered */
#endif
@@ -214,8 +212,6 @@ struct paca_struct {
/* Non-maskable exceptions that are not performance critical */
u64 exnmi[EX_SIZE]; /* used for system reset (nmi) */
u64 exmc[EX_SIZE]; /* used for machine checks */
-#endif
-#ifdef CONFIG_PPC_BOOK3S_64
/* Exclusive stacks for system reset and machine check exception. */
void *nmi_emergency_sp;
void *mc_emergency_sp;
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 9f14d95b8b32..f029755f9e69 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -246,9 +246,7 @@ int main(void)
OFFSET(PACAHWCPUID, paca_struct, hw_cpu_id);
OFFSET(PACAKEXECSTATE, paca_struct, kexec_state);
OFFSET(PACA_DSCR_DEFAULT, paca_struct, dscr_default);
-#ifdef CONFIG_PPC64
OFFSET(PACA_EXIT_SAVE_R1, paca_struct, exit_save_r1);
-#endif
#ifdef CONFIG_PPC_BOOK3E_64
OFFSET(PACA_TRAP_SAVE, paca_struct, trap_save);
#endif
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index 81c9fbae88b1..2cc257f75c50 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -2333,7 +2333,6 @@ static struct pmac_mb_def pmac_mb_defs[] = {
PMAC_TYPE_POWERMAC_G5, g5_features,
0,
},
-#ifdef CONFIG_PPC64
{ "PowerMac7,3", "PowerMac G5",
PMAC_TYPE_POWERMAC_G5, g5_features,
0,
@@ -2359,7 +2358,6 @@ static struct pmac_mb_def pmac_mb_defs[] = {
0,
},
#endif /* CONFIG_PPC64 */
-#endif /* CONFIG_PPC64 */
};
/*
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index b3b94cd37713..f413c220165c 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -643,10 +643,8 @@ static int xmon_core(struct pt_regs *regs, volatile int fromipi)
touch_nmi_watchdog();
} else {
cmd = 1;
-#ifdef CONFIG_SMP
if (xmon_batch)
cmd = batch_cmds(regs);
-#endif
if (!locked_down && cmd)
cmd = cmds(regs);
if (locked_down || cmd != 0) {
--
2.39.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-22 17:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 17:49 [RFC PATCH v2 0/4] remove duplicate ifdefs Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 1/4] sched: " Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 2/4] xfs: " Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 3/4] ntfs: " Shrikanth Hegde
2024-01-22 17:49 ` [RFC PATCH v2 4/4] arch/powerpc: " Shrikanth Hegde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).