Re: [GIT PULL] break implicit percpu.h -> slab.h dependency

Previous thread: [GIT PULL] percpu fixes for 2.6.34-rc3 by Tejun Heo on Sunday, April 4, 2010 - 7:59 pm. (1 message)

Next thread: none
From: Tejun Heo
Date: Sunday, April 4, 2010 - 8:50 pm

Hello, Linus.

Please consider pulling from the following git tree to receive patches
to break implicit inclusion of slab.h from percpu.h.

  git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git slabh

This is rather unusual pull request at this stage in -rc cycles but
given the mostly trivial nature and massive size of this change, I
think it would be beneficial to merge this while the tree isn't
changing too rapidly and as early as possible so that further
breakages aren't introduced.

percpu.h is available to most .c files through module.h and sched.h.
percpu.h has always included slab.h making all gfp and slab
declarations implicitly available in most .c files.  This leads to
unnecessary inclusion dependency loops.  This patchset tries to remedy
the situation by breaking the implicit inclusion.  For more details on
the background and how the conversion is done, please refer to the
following two threads.

  http://thread.gmane.org/gmane.linux.kernel/960180
  http://thread.gmane.org/gmane.linux.kernel/965549

The initial version was tested on x86[_64], powerpc[64], sparc[64],
ia64, s390, alpha and um (on x86_64) w/ mostly allmodconfig.  With the
initial test results and the linux-next testing in the last week, I
believe the conversion is quite comprehensive.  Most of the breakages
found during linux-next testing were in the new code which weren't in
mainline and after Stephen's fixes and automatic conversion pass on
the merged tree, very few breakages have been reported.  Patches for
code which were not in mainline yet have been sent to respective
subsystem maintainers.

It's possible that arch headers on archs which haven't been tested yet
break (couldn't convert them automatically due to the danger of
introducing dependency hell) but those breakages should be rare and
easy to spot and fix.

This pull request contains the following changes.  The only mildly
interesting change is in include/linux/percpu.h and mm/percpu_up.c
which actually breaks the dependency.  ...
From: Ingo Molnar
Date: Tuesday, April 6, 2010 - 2:25 am

FYI, -tip testing found a build breakage with your changes:

 drivers/base/node.c:373: error: implicit declaration of function 'kmalloc'
 drivers/base/node.c:377: error: implicit declaration of function 'kfree'

The fix is below. Since my first test today triggered a build failure i'd 
expect there to be more - i'll send all subsequent fixes to this thread.

Thanks,

	Ingo

Index: linux2/drivers/base/node.c
===================================================================
--- linux2.orig/drivers/base/node.c
+++ linux2/drivers/base/node.c
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/swap.h>
 #include <linux/gfp.h>
+#include <linux/slab.h>
 
 static struct sysdev_class_attribute *node_state_attrs[];
 
--

From: Tejun Heo
Date: Tuesday, April 6, 2010 - 2:38 am

Hello, Ingo.


These are NODEMASK_ALLOC() and NODEMASK_FREE() macros which become
kmalloc/kfree() iff NODES_SHIFT > 8.  I'll grep for these macros and

Thanks.  Much appreciated.

-- 
tejun
--

From: Ingo Molnar
Date: Tuesday, April 6, 2010 - 2:50 am

It's looking pretty good so far with about a dozen tests passed. Thanks for 
doing this transition so carefully!

	Ingo
--

From: Tejun Heo
Date: Tuesday, April 6, 2010 - 2:41 pm

NODEMASK_ALLOC/FREE are mapped to kmalloc/free if NODES_SHIFT > 8.
Among its several users, drivers/base/node.c wasn't including slab.h
leading to build failure if NODES_SHIFT > 8.  Include slab.h from
drivers/base/node.c.

This isn't an ideal solution but including slab.h directly from
nodemask.h is not an option because nodemask.h gets included
everywhere.  For now, make it work by including slab.h from its users.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Ingo Molnar <mingo@elte.hu>
---
 drivers/base/node.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 985abd7..057979a 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -15,7 +15,7 @@
 #include <linux/cpu.h>
 #include <linux/device.h>
 #include <linux/swap.h>
-#include <linux/gfp.h>
+#include <linux/slab.h>

 static struct sysdev_class_attribute *node_state_attrs[];

-- 
1.6.4.2

--

From: Tejun Heo
Date: Tuesday, April 6, 2010 - 2:53 pm

Linus, can you please pull once more from the slabh branch?

  git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git slabh

It has the following single fix for build failure spotted by Ingo
during -tip testing.

Thanks.

Tejun Heo (1):
      nodemask: include slab.h from drivers/base/node.c

 drivers/base/node.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

-- 
tejun
--

Previous thread: [GIT PULL] percpu fixes for 2.6.34-rc3 by Tejun Heo on Sunday, April 4, 2010 - 7:59 pm. (1 message)

Next thread: none