Re: [PATCH] Simplify net/flow.c
From: Andrew Morton
Date: Thu Jan 22 2004 - 22:52:57 EST
"David S. Miller" <davem@xxxxxxxxxx> wrote:
>
> On Thu, 22 Jan 2004 18:49:37 +1100
> Rusty Russell <rusty@xxxxxxxxxxxxxxx> wrote:
>
> > I still have this cleanup sitting around, and frankly it gets
> > in the way for the hotplug CPU code. It works fine here, and is
> > basically trivial, but I'm happy to put it in -mm first for wider
> > testing if you want?
>
> No, I made you wait long enough with this patch :) and I just read it
> over again a few times and it looks perfectly fine.
>
> So I'm applying this now, thanks Rusty.
It doesn't link if CONFIG_SMP=n. semaphore `cpucontrol', used in
flow_cache_flush() is defined in kernel/cpu.c which is not included in
uniprocessor builds.
Here's one possible fix.
diff -puN net/core/flow.c~flow-cpucontrol-fix net/core/flow.c
--- 25/net/core/flow.c~flow-cpucontrol-fix 2004-01-22 19:39:54.000000000 -0800
+++ 25-akpm/net/core/flow.c 2004-01-22 19:43:58.000000000 -0800
@@ -286,7 +286,7 @@ void flow_cache_flush(void)
/* Don't want cpus going down or up during this, also protects
* against multiple callers. */
- down(&cpucontrol);
+ down_cpucontrol();
atomic_set(&info.cpuleft, num_online_cpus());
init_completion(&info.completion);
@@ -296,7 +296,7 @@ void flow_cache_flush(void)
local_bh_enable();
wait_for_completion(&info.completion);
- up(&cpucontrol);
+ up_cpucontrol();
}
static void __devinit flow_cache_cpu_prepare(int cpu)
diff -puN include/linux/cpu.h~flow-cpucontrol-fix include/linux/cpu.h
--- 25/include/linux/cpu.h~flow-cpucontrol-fix 2004-01-22 19:42:23.000000000 -0800
+++ 25-akpm/include/linux/cpu.h 2004-01-22 19:43:35.000000000 -0800
@@ -37,7 +37,12 @@ extern int register_cpu_notifier(struct
extern void unregister_cpu_notifier(struct notifier_block *nb);
int cpu_up(unsigned int cpu);
+
+#define down_cpucontrol() down(&cpucontrol)
+#define up_cpucontrol() up(&cpucontrol)
+
#else
+
static inline int register_cpu_notifier(struct notifier_block *nb)
{
return 0;
@@ -45,6 +50,10 @@ static inline int register_cpu_notifier(
static inline void unregister_cpu_notifier(struct notifier_block *nb)
{
}
+
+#define down_cpucontrol() do { } while (0)
+#define up_cpucontrol() do { } while (0)
+
#endif /* CONFIG_SMP */
extern struct sysdev_class cpu_sysdev_class;
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/