Re: [bisected] Driver core fixes for 3.6-rc3 regression

2012-08-18 Thread Markus Trippelsdorf
On 2012.08.18 at 17:08 -0700, Linus Torvalds wrote:
> On Sat, Aug 18, 2012 at 12:32 PM, Markus Trippelsdorf
>  wrote:
> >
> > Yes. Everything is fine again with this patch applied.
> 
> Ok, can you write a commit message and sign off on it, and I'll apply
> it (or Greg will, either way that message/sign-off would be needed for
> proper patch flow).

Jim already posted a proper patch while I was asleep:
http://lkml.org/lkml/2012/8/18/181
Lets follow up from there.

-- 
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Patch: Thermostat doesn't cool Harddrives (12 inch Powerbooks, Ibooks G4)

2012-08-18 Thread Calvin Walton
On Sat, 2012-08-18 at 11:57 +0200, Thomas Haschka wrote:
> Hello everybody!

Hi Thomas,
Unfortunately, there are quite a few things wrong with your patch that
will likely prevent any kernel developers from picking it up as-is.
Please read through the file Documentation/SubmittingPatches, it has a
lot of helpful hints.

I've added a few more comments inline...

> It was quite hot here in Austria in the recent days and I found out
> that the fan in my 12 inch powerbook only kicked in on CPU, GPU usage,
> while on Mac OS X sides the fan ran nearly all the time (hot as it
> was)... 
> 
> I looked into the therm_adt746 driver and found out that the
> temperature sensor at the harddrive's bottom in the powerbook was not
> taken into account, but it should as one of the air inlets is just
> besides the harddrive, and it is thus also cooled by the fan, ( on can
> verfy that by spinning up the fans an reading out the hdd temp ) .. 
> 
> I created a patch to fix the situation, and I guess that it is pretty
> urgent as I imagine lot's of powerbooks running with their disk
> uncooled.. 
> 
> Here goes the patch
> 
> Thanks for making it accessible.. 
> 
> Thomas

You're missing the Signed-off-by line here. (It's described in the
SubmittingPatches file). Your patch description is pretty good - it
explains clearly why someone would want the patch.

> diff -uprN linux/drivers/macintosh/therm_adt746x.c
> linux-mod/drivers/macintosh/therm_adt746x.c ---
> linux/drivers/macintosh/therm_adt746x.c   2012-08-10
> 12:42:38.0 +0200 +++
> linux-mod/drivers/macintosh/therm_adt746x.c   2012-08-18
> 11:29:41.0 +0200 @@ -2,6 +2,7 @@

This patch has been word-wrapped and mangled by your email client, and
cannot be applied. The file Documentation/email-clients.txt in the
kernel source has some hints on how to set up your email client to avoid
this problem. (If you're using the Gmail web interface for this, you'll
have to use another client: the Gmail web interface cannot be fixed.)
 
> -static u8 TEMP_REG[3]= {0x26, 0x25, 0x27}; /* local, sensor1,
> sensor2 */ -static u8 LIMIT_REG[3]   = {0x6b, 0x6a, 0x6c}; /* local,
> sensor1, sensor2 */ -static u8 MANUAL_MODE[2] = {0x5c, 0x5d};   
> -static u8 REM_CONTROL[2] = {0x00, 0x40};
> -static u8 FAN_SPEED[2]   = {0x28, 0x2a};
> -static u8 FAN_SPD_SET[2] = {0x30, 0x31};
> -
> -static u8 default_limits_local[3] = {70, 50, 70};/* local,
> sensor1, sensor2 */ -static u8 default_limits_chip[3] = {80, 65,
> 80};/* local, sensor1, sensor2 */ -static const char
> *sensor_location[3] = { "?", "?", "?" }; +static u8 TEMP_REG[3] =
> { 0x26, 0x25, 0x27 }; /* local, sensor1, sensor2 */ +static u8
> LIMIT_REG[3] = { 0x6b, 0x6a, 0x6c };  /* local, sensor1, sensor2
> */ +static u8 MANUAL_MODE[2] = { 0x5c, 0x5d }; +static u8
> REM_CONTROL[2] = { 0x00, 0x40 }; +static u8 FAN_SPEED[2] = { 0x28,
> 0x2a }; +static u8 FAN_SPD_SET[2] = { 0x30, 0x31 };
> +
> +static u8 default_limits_local[3] = { 45, 50, 70 };  /* local,
> sensor1, sensor2 */ +static u8 default_limits_chip[3] = { 70, 65,
> 80 }; /* local, sensor1, sensor2 */ +
> +static const char *sensor_location[3];
>  
>  static int limit_adjust;
>  static int fan_speed = -1;
> -static bool verbose;
> +static int verbose;

You've scattered around quite a few code changes that do things like
change types, indentation, or variable names. You even re-order a couple
functions later on in the code! Your patch says that it's adding support
for reading the hard driver temperature sensor - these formatting
changes don't seem to be related to that goal. (And if they are, you
should mention them in the commit message.)

If you want to clean up the formatting of the source code, feel free to
do so; but it should be done as a separate patch from this one, so that
the individual feature changes and formatting changes can be reviewed
separately. Right now I can't even tell which parts of the patch are
functional changes, related to the goal of cooling your hard drive.

-- 
Calvin Walton 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 04/11] x86/microcode_core_early.c: Define interfaces for early load ucode

2012-08-18 Thread H. Peter Anvin
On 08/18/2012 07:38 PM, Yu, Fenghua wrote:
> 
> In this early phase, detecting vendor in initrd is much simpler code.
> Otherwise, detecting vendor by cpuid (and without cpuid) needs
> similar but different code as existing functions and coding would be
> awkward.
> 

I'm confused by this statement.  Getting the vendor from CPUID is a few
lines of code, and non-CPUID processors don't support microcode loading.

> Why name it ".hex" when you're loading binary data?  I suggest ".bin".  It
> is confusing to have .hex there, since you're not dealing with the Intel HEX
> format, nor anything text-like.

Actually I think we can also skip one level of indirection here... no
need to mention "microcode" twice.

kernel/x86/microcode/GenuineIntel or GenuineIntel.bin seems good
enough... the idea here of course is that the string can come from CPUID.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/11] x86/lib/cpio.c: Find cpio data by its file name

2012-08-18 Thread H. Peter Anvin
On 08/18/2012 09:35 PM, Henrique de Moraes Holschuh wrote:
> On Sat, 18 Aug 2012, Yu, Fenghua wrote:
>>> From: Henrique de Moraes Holschuh [mailto:h...@hmh.eng.br] On Sat, 18 Aug
>>> 2012, Fenghua Yu wrote:
 Given a file's name, find its starting point in a cpio formated area.
>>> This will
 be used to find microcode in combined initrd image. But this function
>>> is
 generic and could be used in other places.
>>>
>>> Shouldn't this (very useful) feature get its own documentation in
>>> Documentation/ ?
>>
>> Yes, I can document the feature. And if it's generic and useful, this
>> function could be put in generic kernel instead of in x86 arch.
> 
> It is useful to override/fix all sort of critical firmware-provided tables,
> for example.  ACPI table overrides should use this new cpio-based scheme as
> well, and I recall someone wrote something about device tree overrides in a
> past thread...
> 

Indeed, we already have those two users already identified.

-hpa


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 14/31] sections: Fix section conflicts in drivers/hwmon

2012-08-18 Thread Guenter Roeck
On Sun, Aug 19, 2012 at 03:59:11AM +0200, Andi Kleen wrote:
> On Sat, Aug 18, 2012 at 04:23:04PM -0700, Guenter Roeck wrote:
> > On Sat, Aug 18, 2012 at 10:30:05AM -0700, Andi Kleen wrote:
> > > From: Andi Kleen 
> > > 
> > > Signed-off-by: Andi Kleen 
> > 
> > Applied.
> > 
> 
> Thanks.
> 
> > Looks like you did not include maintainers and/or subject mailing lists in 
> > your
> > patch series, so I guess you won't get much feedback.
> 
> Tree sweeps like this normally don't go through individual mainainers, it's 
> just
> not practical.
> 
That is not the point. For my part I still like to know what is going on, at
the very least to be able to avoid conflicts, and some maintainers tend to get
a bit tense if they are not informed. Besides, I would consider it to be a
common courtesy to inform maintainers about activity related to their area of
responsibility.

If you want the patch to go through some other tree, fine with me; I can drop it
and give it an Ack. Your e-mail does not mention a target tree, though, and my
psychic capabilities seem to be a bit erratic lately ;).

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] edac: edac_mc no longer deals with kobjects directly.

2012-08-18 Thread Shaun Ruffell
There are no more embedded kobjects in struct mem_ctl_info. Remove a header and
a comment that does not reflect the code anymore.

Signed-off-by: Shaun Ruffell 
---
 drivers/edac/edac_mc.c | 7 ---
 include/linux/edac.h   | 1 -
 2 files changed, 8 deletions(-)

diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index a58facc..65c59b1 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -433,13 +433,6 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
 
mci->op_state = OP_ALLOC;
 
-   /* at this point, the root kobj is valid, and in order to
-* 'free' the object, then the function:
-*  edac_mc_unregister_sysfs_main_kobj() must be called
-* which will perform kobj unregistration and the actual free
-* will occur during the kobject callback operation
-*/
-
return mci;
 
 error:
diff --git a/include/linux/edac.h b/include/linux/edac.h
index bab9f84..aeddb3f 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -14,7 +14,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
1.7.11.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] Fix edac_mc crash in e7xxx_edac error path.

2012-08-18 Thread Shaun Ruffell
With kernel version 3.6-rc2 on a Dell Poweredge 2600 I experienced a NULL
pointer dereference that did not occur with on 3.5. I believe the error is
related to commit de3910eb79a "edac: change the mem allocation scheme to make
Documentation/kobject.txt happy" [1] and the fact that my system is going
through an error path in the e7xxx_edac driver.

[1] 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=de3910eb79ac8c0f29a11224661c0ebaaf813039

This is the OOPS:

 [  36.703479] BUG: unable to handle kernel NULL pointer dereference at   (null)
 [  36.703479] IP: [] __wake_up_common+0x1a/0x6a
 [  36.703479] *pde = 7f0c6067 
 [  36.703479] Oops:  [#1] SMP 
 [  36.703479] Modules linked in: parport_pc parport floppy e7xxx_edac(+) 
ide_cd_mod edac_core intel_rng cdrom microcode(+) dm_snapshot dm_zero dm_mirror 
dm_region_hash d
 [  36.703479] Pid: 933, comm: modprobe Tainted: GW
3.6.0-rc2-00111-gc1999ee #12 Dell Computer Corporation PowerEdge 2600   
  /0F0364
 [  36.703479] EIP: 0060:[] EFLAGS: 00010093 CPU: 3
 [  36.703479] EIP is at __wake_up_common+0x1a/0x6a
 [  36.703479] EAX: f47b0984 EBX: fff4 ECX:  EDX: 0003
 [  36.703479] ESI: f47b0984 EDI: 0282 EBP: f3dc7d38 ESP: f3dc7d1c
 [  36.703479]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
 [  36.703479] CR0: 8005003b CR2:  CR3: 347d4000 CR4: 07d0
 [  36.703479] DR0:  DR1:  DR2:  DR3: 
 [  36.703479] DR6: 0ff0 DR7: 0400
 [  36.703479] Process modprobe (pid: 933, ti=f3dc6000 task=f3db9520 
task.ti=f3dc6000)
 [  36.703479] Stack:
 [  36.703479]    0003 c046701a f47b0980 f47b0984 0282 
f3dc7d54
 [  36.703479]  c046703f   f47b08b0 f47b08b0  f3dc7d74 
c06961ce
 [  36.703479]  f3dc7d74 f3dc7d80 c05e2837 c094c4cc f47b08b0 f47b08b0 f3dc7d88 
c068d56d
 [  36.703479] Call Trace:
 [  36.703479]  [] ? complete_all+0x1a/0x50
 [  36.703479]  [] complete_all+0x3f/0x50
 [  36.703479]  [] device_pm_remove+0x23/0xa2
 [  36.703479]  [] ? kobject_put+0x5b/0x5d
 [  36.703479]  [] device_del+0x34/0x142
 [  36.703479]  [] edac_unregister_sysfs+0x3b/0x5c [edac_core]
 [  36.703479]  [] edac_mc_free+0x29/0x2f [edac_core]
 [  36.703479]  [] e7xxx_probe1+0x268/0x311 [e7xxx_edac]
 [  36.703479]  [] ? __pci_enable_device_flags+0x8f/0xd3
 [  36.703479]  [] e7xxx_init_one+0x56/0x61 [e7xxx_edac]
 [  36.703479]  [] local_pci_probe+0x13/0x15
 [  36.703479]  [] pci_call_probe+0x1c/0x1e
 [  36.703479]  [] __pci_device_probe+0x41/0x4e
 [  36.703479]  [] pci_device_probe+0x26/0x39
 [  36.703479]  [] really_probe+0x101/0x2a1
 [  36.703479]  [] ? __driver_attach+0x3d/0x6e
 [  36.703479]  [] ? __driver_attach+0x3d/0x6e
 [  36.703479]  [] ? quirk_usb_disable_ehci+0xa3/0x141
 [  36.703479]  [] driver_probe_device+0x35/0x79
 [  36.703479]  [] __driver_attach+0x6c/0x6e
 [  36.703479]  [] bus_for_each_dev+0x44/0x62
 [  36.703479]  [] driver_attach+0x1e/0x20
 [  36.703479]  [] ? device_attach+0x98/0x98
 [  36.703479]  [] bus_add_driver+0xc5/0x1c8
 [  36.703479]  [] ? store_new_id+0xfa/0xfa
 [  36.703479]  [] driver_register+0x52/0xd6
 [  36.703479]  [] ? 0xf8603fff
 [  36.703479]  [] __pci_register_driver+0x4b/0x73
 [  36.703479]  [] ? 0xf8603fff
 [  36.703479]  [] e7xxx_init+0x55/0x57 [e7xxx_edac]
 [  36.703479]  [] do_one_initcall+0xa3/0xe0
 [  36.703479]  [] sys_init_module+0x70/0x1af
 [  36.703479]  [] ? trace_hardirqs_on_caller+0x56/0xf9
 [  36.703479]  [] ? trace_hardirqs_on_thunk+0xc/0x10
 [  36.703479]  [] sysenter_do_call+0x12/0x32
 [  36.703479] Code: 5d c3 55 89 e5 3e 8d 74 26 00 e8 8f ff ff ff 5d c3 55 89 
e5 57 56 53 83 ec 10 3e 8d 74 26 00 89 55 ec 89 4d e8 8b 58 28 83 eb 0c <8b> 53 
0c 83 c0 28
 [  36.703479] EIP: [] __wake_up_common+0x1a/0x6a SS:ESP 0068:f3dc7d1c
 [  36.703479] CR2: 
 [  36.703479] ---[ end trace 6fcfddc0eef7bbd8 ]---

When I enabled edac debugging I saw the following printed to the kernel log
prior to the above BUG:

  EDAC MC: Ver: 3.0.0
  EDAC DEBUG: edac_mc_sysfs_init: device mc created
  EDAC DEBUG: e7xxx_init_one:
  EDAC DEBUG: e7xxx_probe1: mci
  EDAC DEBUG: edac_mc_alloc: errcount layer 0 size 8
  EDAC DEBUG: edac_mc_alloc: errcount layer 1 size 16
  EDAC DEBUG: edac_mc_alloc: allocating 48 error counters
  EDAC DEBUG: edac_mc_alloc: allocating 1068 bytes for mci data (16 ranks, 16 
csrows/channels)
  EDAC DEBUG: e7xxx_probe1: init mci
  EDAC DEBUG: e7xxx_probe1: init pvt
  EDAC e7xxx: error reporting device not found:vendor 8086 device 0x2541 
(broken BIOS?)
  EDAC DEBUG: edac_mc_free:
  Floppy drive(s): fd0 is 1.44M
  EDAC DEBUG: edac_unregister_sysfs: Unregistering device (null)

There are probably better ways to accomplish what the following patches are
doing but I thought I would send along what I had if only to motivate any
discussion. I also have resent Fengguang Wu's patch in this series since I found
that it was required as well.

Shaun Ruffell (2):
  edac: Remove invalid kfree 

[PATCH 2/3] edac: edac_mc_free() cannot assume mem_ctl_info is registered in sysfs.

2012-08-18 Thread Shaun Ruffell
edac_mc_free() may need to deallocate any memory associated with struct
mem_ctl_info directly if the structure was never registered with sysfs in
edac_mc_add_mc(). This moves the error handling code from edac_mc_alloc() into a
dedicated function to be called by edac_mc_free() as well if necessary.

This resolves a NULL pointer dereference from the following code path first
introduced in 3.6-rc1:

  EDAC MC: Ver: 3.0.0
  EDAC DEBUG: edac_mc_sysfs_init: device mc created
  EDAC DEBUG: e7xxx_init_one:
  EDAC DEBUG: e7xxx_probe1: mci
  EDAC DEBUG: edac_mc_alloc: errcount layer 0 size 8
  EDAC DEBUG: edac_mc_alloc: errcount layer 1 size 16
  EDAC DEBUG: edac_mc_alloc: allocating 48 error counters
  EDAC DEBUG: edac_mc_alloc: allocating 1068 bytes for mci data (16 ranks, 16 
csrows/channels)
  EDAC DEBUG: e7xxx_probe1: init mci
  EDAC DEBUG: e7xxx_probe1: init pvt
  EDAC e7xxx: error reporting device not found:vendor 8086 device 0x2541 
(broken BIOS?)
  EDAC DEBUG: edac_mc_free:
  Floppy drive(s): fd0 is 1.44M
  EDAC DEBUG: edac_unregister_sysfs: Unregistering device (null)

Signed-off-by: Shaun Ruffell 
---
 drivers/edac/edac_mc.c | 59 +-
 1 file changed, 39 insertions(+), 20 deletions(-)

diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 9037ffa..a58facc 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -199,6 +199,36 @@ void *edac_align_ptr(void **p, unsigned size, int n_elems)
return (void *)(((unsigned long)ptr) + align - r);
 }
 
+static void _edac_mc_free(struct mem_ctl_info *mci)
+{
+   int i, chn, row;
+   struct csrow_info *csr;
+   const unsigned int tot_dimms = mci->tot_dimms;
+   const unsigned int tot_channels = mci->num_cschannel;
+   const unsigned int tot_csrows = mci->nr_csrows;
+
+   if (mci->dimms) {
+   for (i = 0; i < tot_dimms; i++)
+   kfree(mci->dimms[i]);
+   kfree(mci->dimms);
+   }
+   if (mci->csrows) {
+   for (row = 0; row < tot_csrows; row++) {
+   csr = mci->csrows[row];
+   if (csr) {
+   if (csr->channels) {
+   for (chn = 0; chn < tot_channels; chn++)
+   kfree(csr->channels[chn]);
+   kfree(csr->channels);
+   }
+   kfree(csr);
+   }
+   }
+   kfree(mci->csrows);
+   }
+   kfree(mci);
+}
+
 /**
  * edac_mc_alloc: Allocate and partially fill a struct mem_ctl_info structure
  * @mc_num:Memory controller number
@@ -413,26 +443,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
return mci;
 
 error:
-   if (mci->dimms) {
-   for (i = 0; i < tot_dimms; i++)
-   kfree(mci->dimms[i]);
-   kfree(mci->dimms);
-   }
-   if (mci->csrows) {
-   for (row = 0; row < tot_csrows; row++) {
-   csr = mci->csrows[row];
-   if (csr) {
-   if (csr->channels) {
-   for (chn = 0; chn < tot_channels; chn++)
-   kfree(csr->channels[chn]);
-   kfree(csr->channels);
-   }
-   kfree(csr);
-   }
-   }
-   kfree(mci->csrows);
-   }
-   kfree(mci);
+   _edac_mc_free(mci);
 
return NULL;
 }
@@ -447,6 +458,14 @@ void edac_mc_free(struct mem_ctl_info *mci)
 {
edac_dbg(1, "\n");
 
+   /* If we're not yet registered with sysfs free only what was allocated
+* in edac_mc_alloc().
+*/
+   if (!mci->bus.name) {
+   _edac_mc_free(mci);
+   return;
+   }
+
/* the mci instance is freed here, when the sysfs object is dropped */
edac_unregister_sysfs(mci);
 }
-- 
1.7.11.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] edac_mc: fix kfree calls in the error path

2012-08-18 Thread Shaun Ruffell
From: Fengguang Wu 

We need to free up memory in this order:

  free csrows[i]->channels[j]
  free csrows[i]->channels
  free csrows[i]
  free csrows

Signed-off-by: Fengguang Wu 
---
 drivers/edac/edac_mc.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 616d90b..9037ffa 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -419,14 +419,16 @@ error:
kfree(mci->dimms);
}
if (mci->csrows) {
-   for (chn = 0; chn < tot_channels; chn++) {
-   csr = mci->csrows[chn];
+   for (row = 0; row < tot_csrows; row++) {
+   csr = mci->csrows[row];
if (csr) {
-   for (chn = 0; chn < tot_channels; chn++)
-   kfree(csr->channels[chn]);
+   if (csr->channels) {
+   for (chn = 0; chn < tot_channels; chn++)
+   kfree(csr->channels[chn]);
+   kfree(csr->channels);
+   }
kfree(csr);
}
-   kfree(mci->csrows[i]);
}
kfree(mci->csrows);
}
-- 
1.7.11.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 04/11] x86/microcode_core_early.c: Define interfaces for early load ucode

2012-08-18 Thread Henrique de Moraes Holschuh
On Sun, 19 Aug 2012, Yu, Fenghua wrote:
> > From: Henrique de Moraes Holschuh [mailto:h...@hmh.eng.br]
> > On Sat, 18 Aug 2012, Fenghua Yu wrote:
> > > + char ucode_name[] =
> > "kernel/x86/microcode/GenuineIntel/microcode.hex";
> > 
> > Why name it ".hex" when you're loading binary data?  I suggest ".bin".
> > It
> > is confusing to have .hex there, since you're not dealing with the
> > Intel HEX
> > format, nor anything text-like.
> > 
> > > +void __init load_ucode_bsp(char *real_mode_data)
> > > +{
> > > + u64 ramdisk_image, ramdisk_size, ramdisk_end;
> > > + unsigned long initrd_start, initrd_end;
> > > + struct boot_params *boot_params;
> > > +
> > > + boot_params = (struct boot_params *)real_mode_data;
> > > + ramdisk_image = boot_params->hdr.ramdisk_image;
> > > + ramdisk_size  = boot_params->hdr.ramdisk_size;
> > > +
> > > +#ifdef CONFIG_X86_64
> > > + ramdisk_end  = PAGE_ALIGN(ramdisk_image + ramdisk_size);
> > > + initrd_start = ramdisk_image + PAGE_OFFSET;
> > > +#else
> > > + ramdisk_end  = ramdisk_image + ramdisk_size;
> > > + initrd_start = ramdisk_image;
> > > +#endif
> > > + initrd_end = initrd_start + ramdisk_size;
> > > +
> > > + /*
> > > +  * It's early to get CPU vendor info at this point.
> > > +  * By searching initrd to find right name for vendor's microcode,
> > > +  * it's relative easier to get CPU vendor info.
> > > +  */
> > > + if (find_ucode_intel(initrd_start, initrd_end) == UCODE_OK)
> > > + load_ucode_intel_bsp(real_mode_data);
> > > +}
> > 
> > I'd say something down the load_ucode_intel_bsp() chain better check
> > the CPU
> > vendor to make sure the Intel driver won't attempt to load microcode on
> > some
> > other vendor's processor.
> > 
> > Or are cpu signatures a global namespace and x86 cpu vendors make sure
> > (past, present and future) to never use the same cpu signature as
> > someone
> > else is going to use?  Anyway, it would still might be a good thing to
> > do
> > the vendor check somewhere to avoid wasting time going over every
> > microcode
> > of the wrong vendor on generic boot images that have both AMD and Intel
> > microcode.
> > 
> 
> In this early phase, detecting vendor in initrd is much simpler code. 
> Otherwise, detecting vendor by cpuid (and without cpuid) needs similar but 
> different code as existing functions and coding would be awkward. 
> 
> I fully thought and agreed the usage complexity you describe here. It might 
> be good thing to do a bit ugly but more practical coding here.

Sure, there is no harm in defering the implementation of this check to later
versions of the patch set.  As long as the final patch set doesn't risk
loading microcode on the wrong vendor or waste a lot of milliseconds trying
to match intel microcode to a non-intel cpu, I have no objections  :-)

But what about the ".hex" naming for the microcode bundle (container) name?
I find it confusing, since the file contains binary data, not structured
text representing binary data using base 16...  this is also something that
is of minor importance, but at least it is a very easy thing to change at
this point.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/11] x86/lib/cpio.c: Find cpio data by its file name

2012-08-18 Thread Henrique de Moraes Holschuh
On Sat, 18 Aug 2012, Yu, Fenghua wrote:
> > From: Henrique de Moraes Holschuh [mailto:h...@hmh.eng.br] On Sat, 18 Aug
> > 2012, Fenghua Yu wrote:
> > > Given a file's name, find its starting point in a cpio formated area.
> > This will
> > > be used to find microcode in combined initrd image. But this function
> > is
> > > generic and could be used in other places.
> > 
> > Shouldn't this (very useful) feature get its own documentation in
> > Documentation/ ?
> 
> Yes, I can document the feature. And if it's generic and useful, this
> function could be put in generic kernel instead of in x86 arch.

It is useful to override/fix all sort of critical firmware-provided tables,
for example.  ACPI table overrides should use this new cpio-based scheme as
well, and I recall someone wrote something about device tree overrides in a
past thread...

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: BUG: unable to handle kernel paging request at 00010016

2012-08-18 Thread Shaun Ruffell
Adding linux-net to the CC list.

On Fri, Aug 17, 2012 at 11:57:56PM +0100, Dave Haywood wrote:
> [1.] One line summary of the problem:
> BUG: unable to handle kernel paging request at 00010016
> 
>   System boots then crashes a 5-10 or so seconds after getting to the 
> login prompt
>   Booting without the network cable attached prevents the crash (no 
> evidence beyond 10 minutes after boot)
> 
>   Diagnostics:
>   Captured the boot and managed a login + dmesg before the crash
>   Some of the log looks corrupted. Probably my crappy usb dongle serial 
> flow control but left it in anyway

[snip]

> [6.] Output of Oops.. message (if applicable) with symbolic information
>  resolved (see Documentation/oops-tracing.txt)
> [   62.907899] BUG: unable to handle kernel paging request at 00010016
> [   62.908002] IP: [] inet6_sk_rx_dst_set+0x29/0x40
> [   62.908002] *pde = 
> [   62.908002] Oops:  [#1] SMP
> [   62.908002] Pid: 2168, comm: mprime Not tainted 3.6.0-rc2 #297 Compaq 
> Deskpro/06C4h
> [   62.908002] EIP: 0060:[] EFLAGS: 00010202 CPU: 0
> [   62.908002] EIP is at inet6_sk_rx_dst_set+0x29/0x40
> [   62.908002] EAX: ce738508 EBX: ce73a760 ECX: cf377000 EDX: 00010002
> [   62.908002] ESI: ca06c900 EDI: ce738000 EBP: cf80bc7c ESP: cf80bc7c
> [   62.908002]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
> [   62.908002] CR0: 80050033 CR2: 00010016 CR3: 0a036000 CR4: 07d0
> [   62.908002] DR0:  DR1:  DR2:  DR3: 
> [   62.908002] DR6: 0ff0 DR7: 0400
> [   62.908002] Process mprime (pid: 2168, ti=cf80a000 task=ce4f7390 
> task.ti=ca052000)
> [   62.908002] Stack:
> [   62.908002]  cf80bc9c c15449cb  ce436780  ce738508 
> ca06c900 ce738000
> [   62.908002]  cf80bcc0 c154337e c167545e cf80bcec c124b318 ce436780 
> ce738508 ce738000
> [   62.908002]  ce436780 cf80bd48 c15aff9d  0001 cf80bcec 
> c1236880 ce691ec0
> [   62.908002] Call Trace:
> [   62.908002]  [] tcp_create_openreq_child+0x3b/0x4a0
> [   62.908002]  [] tcp_v4_syn_recv_sock+0x2e/0x2a0
> [   62.908002]  [] ? _raw_spin_unlock_bh+0xe/0x10
> [   62.908002]  [] ? selinux_netlbl_sock_rcv_skb+0x18/0x190
> [   62.908002]  [] tcp_v6_syn_recv_sock+0x3ed/0x6d0
> [   62.908002]  [] ? selinux_parse_skb+0x50/0xb0
> [   62.908002]  [] tcp_check_req+0x283/0x450
> [   62.908002]  [] tcp_v4_hnd_req+0x51/0x140
> [   62.908002]  [] tcp_v4_do_rcv+0x129/0x1b0
> [   62.908002]  [] ? sk_filter+0x25/0xb0
> [   62.908002]  [] tcp_v4_rcv+0x5fe/0x730
> [   62.908002]  [] ? ip_rcv_finish+0x2f0/0x2f0
> [   62.908002]  [] ip_local_deliver_finish+0x8c/0x260
> [   62.908002]  [] ? inet_del_protocol+0x30/0x30
> [   62.908002]  [] ip_local_deliver+0x7f/0x90
> [   62.908002]  [] ? ip_rcv_finish+0x2f0/0x2f0
> [   62.908002]  [] ip_rcv_finish+0xf1/0x2f0
> [   62.908002]  [] ? inet_del_protocol+0x30/0x30
> [   62.908002]  [] ip_rcv+0x252/0x320
> [   62.908002]  [] ? inet_del_protocol+0x30/0x30
> [   62.908002]  [] __netif_receive_skb+0x46b/0x670
> [   62.908002]  [] netif_receive_skb+0x22/0x80
> [   62.908002]  [] rtl8139_rx+0xd2/0x370
> [   62.908002]  [] rtl8139_poll+0x42/0xb0
> [   62.908002]  [] net_rx_action+0xed/0x1c0
> [   62.908002]  [] ? fbcon_add_cursor_timer+0xd0/0xd0
> [   62.908002]  [] __do_softirq+0xa7/0x200
> [   62.908002]  [] ? local_bh_enable_ip+0x80/0x80
> [   62.908002]  
> [   62.908002]  [] ? irq_exit+0x6e/0x90
> [   62.908002]  [] ? do_IRQ+0x46/0xb0
> [   62.908002]  [] ? irq_exit+0x57/0x90
> [   62.908002]  [] ? smp_apic_timer_interrupt+0x56/0x90
> [   62.908002]  [] ? common_interrupt+0x29/0x30
> [   62.908002] Code: 90 90 55 8b 4a 48 89 e5 83 e1 fe 3e ff 41 40 89 88 8c 00 
> 00 00 8b 52 74 89 90 cc 01 00 00 8b 51 58 85 d2 74 0c 8b 80 a0 01 00 00 <8b> 
> 52 14 89 50 68 5d c3 eb 0d 90 90 90 90 90 90 90 90 90 90 90
> [   62.908002] EIP: [] inet6_sk_rx_dst_set+0x29/0x40 SS:ESP 
> 0068:cf80bc7c
> [   62.908002] CR2: 00010016
> [   63.212118] ---[ end trace 1fcc7fe92846c9d3 ]---
> [   63.216734] Kernel panic - not syncing: Fatal exception in interrupt

Just a note that I see this as well. It happens reliably for me after trying to
login to the machine via ssh.

Here is the back trace I collected on the serial port.

[   67.258206] BUG: unable to handle kernel paging request at 00010016
[   67.260010] IP: [] inet6_sk_rx_dst_set+0x3a/0x89 [ipv6]
[   67.260010] *pde = 
[   67.260010] Oops:  [#1] SMP
[   67.260010] Modules linked in: bluetooth rfkill crc16 lockd sunrpc ipv6 
dm_multipath lp sg pcspkr serio_raw e1000 ata_piix libata floppy parport_pc pa 
rport e7xxx_edac edac_core ide_cd_mod cdrom intel_rng dm_snapshot dm_zero 
dm_mirror dm_region_hash dm_log dm_mod megaraid_mbox megaraid_mm sd_mod scsi_mo
d ext3 jbd uhci_hcd ohci_hcd ehci_hcd [last unloaded: microcode]
[   67.260010] Pid: 0, comm: swapper/0 Not tainted 3.6.0-rc2-00117-g741badf #14 
Dell Computer Corporation PowerEdge 2600 /0F0364
[   67.260010] EIP: 0060:[] EFLAGS: 

[tip:x86/urgent] x32: Use compat shims for {g,s}etsockopt

2012-08-18 Thread tip-bot for Mike Frysinger
Commit-ID:  515c7af85ed92696c311c53d53cb4898ff32d784
Gitweb: http://git.kernel.org/tip/515c7af85ed92696c311c53d53cb4898ff32d784
Author: Mike Frysinger 
AuthorDate: Sat, 18 Aug 2012 16:11:37 -0400
Committer:  H. Peter Anvin 
CommitDate: Sat, 18 Aug 2012 14:15:39 -0700

x32: Use compat shims for {g,s}etsockopt

Some of the arguments to {g,s}etsockopt are passed in userland pointers.
If we try to use the 64bit entry point, we end up sometimes failing.

For example, dhcpcd doesn't run in x32:
# dhcpcd eth0
dhcpcd[1979]: version 5.5.6 starting
dhcpcd[1979]: eth0: broadcasting for a lease
dhcpcd[1979]: eth0: open_socket: Invalid argument
dhcpcd[1979]: eth0: send_raw_packet: Bad file descriptor

The code in particular is getting back EINVAL when doing:
struct sock_fprog pf;
setsockopt(s, SOL_SOCKET, SO_ATTACH_FILTER, , sizeof(pf));

Diving into the kernel code, we can see:
include/linux/filter.h:
struct sock_fprog {
unsigned short len;
struct sock_filter __user *filter;
};

net/core/sock.c:
case SO_ATTACH_FILTER:
ret = -EINVAL;
if (optlen == sizeof(struct sock_fprog)) {
struct sock_fprog fprog;

ret = -EFAULT;
if (copy_from_user(, optval, sizeof(fprog)))
break;

ret = sk_attach_filter(, sk);
}
break;

arch/x86/syscalls/syscall_64.tbl:
54 common setsockopt sys_setsockopt
55 common getsockopt sys_getsockopt

So for x64, sizeof(sock_fprog) is 16 bytes.  For x86/x32, it's 8 bytes.
This comes down to the pointer being 32bit for x32, which means we need
to do structure size translation.  But since x32 comes in directly to
sys_setsockopt, it doesn't get translated like x86.

After changing the syscall table and rebuilding glibc with the new kernel
headers, dhcp runs fine in an x32 userland.

Oddly, it seems like Linus noted the same thing during the initial port,
but I guess that was missed/lost along the way:
https://lkml.org/lkml/2011/8/26/452

[ hpa: tagging for -stable since this is an ABI fix. ]

Bugzilla: https://bugs.gentoo.org/423649
Reported-by: Mads 
Signed-off-by: Mike Frysinger 
Link: 
http://lkml.kernel.org/r/1345320697-15713-1-git-send-email-vap...@gentoo.org
Cc: H. J. Lu 
Cc:  v3.4..v3.5
Signed-off-by: H. Peter Anvin 
---
 arch/x86/syscalls/syscall_64.tbl |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
index 29aed7a..a582bfe 100644
--- a/arch/x86/syscalls/syscall_64.tbl
+++ b/arch/x86/syscalls/syscall_64.tbl
@@ -60,8 +60,8 @@
 51 common  getsockname sys_getsockname
 52 common  getpeername sys_getpeername
 53 common  socketpair  sys_socketpair
-54 common  setsockopt  sys_setsockopt
-55 common  getsockopt  sys_getsockopt
+54 64  setsockopt  sys_setsockopt
+55 64  getsockopt  sys_getsockopt
 56 common  clone   stub_clone
 57 common  forkstub_fork
 58 common  vfork   stub_vfork
@@ -353,3 +353,5 @@
 538x32 sendmmsgcompat_sys_sendmmsg
 539x32 process_vm_readvcompat_sys_process_vm_readv
 540x32 process_vm_writev   compat_sys_process_vm_writev
+541x32 setsockopt  compat_sys_setsockopt
+542x32 getsockopt  compat_sys_getsockopt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 48/74] x86, lto: Use inline assembler instead of global register variable to get sp

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

LTO in gcc 4.6/47. has trouble with global register variables. They were used
to read the stack pointer. Use a simple inline assembler statement instead.

I verified this generates the same binary (on 64bit) as the original
register variable.

Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/thread_info.h |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/thread_info.h 
b/arch/x86/include/asm/thread_info.h
index 89f794f..d9fbfa1 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -167,9 +167,11 @@ struct thread_info {
  */
 #ifndef __ASSEMBLY__
 
-
-/* how to get the current stack pointer from C */
-register unsigned long current_stack_pointer asm("esp") __used;
+#define current_stack_pointer ({   \
+   unsigned long sp;   \
+   asm("mov %%esp,%0" : "=r" (sp));\
+   sp; \
+})
 
 /* how to get the thread information struct from C */
 static inline struct thread_info *current_thread_info(void)
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 36/74] lto, crypto, camelia: Make camelia tables used by assembler __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Cc: herb...@gondor.apana.org.au
Signed-off-by: Andi Kleen 
---
 arch/x86/crypto/camellia_glue.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c
index eeb2b3b..f290db7 100644
--- a/arch/x86/crypto/camellia_glue.c
+++ b/arch/x86/crypto/camellia_glue.c
@@ -91,7 +91,7 @@ static void camellia_decrypt(struct crypto_tfm *tfm, u8 *dst, 
const u8 *src)
 }
 
 /* camellia sboxes */
-const u64 camellia_sp1000[256] = {
+__visible const u64 camellia_sp1000[256] = {
0x707070707000, 0x828282828200, 0x2c2c2c2c2c00,
0xececececec00, 0xb3b3b3b3b300, 0x272727272700,
0xc0c0c0c0c000, 0xe5e5e5e5e500, 0xe4e4e4e4e400,
@@ -180,7 +180,7 @@ const u64 camellia_sp1000[256] = {
0x9e9e9e9e9e00,
 };
 
-const u64 camellia_sp22000222[256] = {
+__visible const u64 camellia_sp22000222[256] = {
0xe0e000e0e0e0, 0x050500050505, 0x585800585858,
0xd9d900d9d9d9, 0x676700676767, 0x4e4e004e4e4e,
0x818100818181, 0xcbcb00cbcbcb, 0xc9c900c9c9c9,
@@ -269,7 +269,7 @@ const u64 camellia_sp22000222[256] = {
0x3d3d003d3d3d,
 };
 
-const u64 camellia_sp03303033[256] = {
+__visible const u64 camellia_sp03303033[256] = {
0x0038380038003838, 0x0041410041004141, 0x0016160016001616,
0x0076760076007676, 0x00d9d900d900d9d9, 0x0093930093009393,
0x0060600060006060, 0x00f2f200f200f2f2, 0x0072720072007272,
@@ -358,7 +358,7 @@ const u64 camellia_sp03303033[256] = {
0x004f4f004f004f4f,
 };
 
-const u64 camellia_sp0004[256] = {
+__visible const u64 camellia_sp0004[256] = {
0x707070700070, 0x2c2c2c2c002c, 0xb3b3b3b300b3,
0xc0c0c0c000c0, 0xe4e4e4e400e4, 0x575757570057,
0xeaeaeaea00ea, 0xaeaeaeae00ae, 0x232323230023,
@@ -447,7 +447,7 @@ const u64 camellia_sp0004[256] = {
0x9e9e9e9e009e,
 };
 
-const u64 camellia_sp02220222[256] = {
+__visible const u64 camellia_sp02220222[256] = {
0x00e0e0e000e0e0e0, 0x0005050500050505, 0x0058585800585858,
0x00d9d9d900d9d9d9, 0x0067676700676767, 0x004e4e4e004e4e4e,
0x0081818100818181, 0x00cbcbcb00cbcbcb, 0x00c9c9c900c9c9c9,
@@ -536,7 +536,7 @@ const u64 camellia_sp02220222[256] = {
0x003d3d3d003d3d3d,
 };
 
-const u64 camellia_sp30333033[256] = {
+__visible const u64 camellia_sp30333033[256] = {
0x3800383838003838, 0x4100414141004141, 0x1600161616001616,
0x7600767676007676, 0xd900d9d9d900d9d9, 0x9300939393009393,
0x6000606060006060, 0xf200f2f2f200f2f2, 0x7200727272007272,
@@ -625,7 +625,7 @@ const u64 camellia_sp30333033[256] = {
0x4f004f4f4f004f4f,
 };
 
-const u64 camellia_sp44044404[256] = {
+__visible const u64 camellia_sp44044404[256] = {
0x7070007070700070, 0x2c2c002c2c2c002c, 0xb3b300b3b3b300b3,
0xc0c000c0c0c000c0, 0xe4e400e4e4e400e4, 0x5757005757570057,
0xeaea00eaeaea00ea, 0xaeae00aeaeae00ae, 0x2323002323230023,
@@ -714,7 +714,7 @@ const u64 camellia_sp44044404[256] = {
0x9e9e009e9e9e009e,
 };
 
-const u64 camellia_sp11101110[256] = {
+__visible const u64 camellia_sp11101110[256] = {
0x7070700070707000, 0x8282820082828200, 0x2c2c2c002c2c2c00,
0xececec00ececec00, 0xb3b3b300b3b3b300, 0x2727270027272700,
0xc0c0c000c0c0c000, 0xe5e5e500e5e5e500, 0xe4e4e400e4e4e400,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 18/74] lto, wan/sbni: Make inline assembler symbols visible and assembler global

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

- Inline assembler defining C callable code has to be global
- The function has to be visible

Do this in wan/sbni

Signed-off-by: Andi Kleen 
---
 drivers/net/wan/sbni.c |6 +++---
 drivers/net/wan/sbni.h |2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index d43f4ef..b914ab3 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -160,7 +160,7 @@ static int  scandone__initdata = 0;
 static int  num__initdata = 0;
 
 static unsigned char  rxl_tab[];
-static u32  crc32tab[];
+__visible u32  sbni_crc32tab[];
 
 /* A list of all installed devices, for removing the driver module. */
 static struct net_device  *sbni_cards[ SBNI_MAX_NUM_CARDS ];
@@ -1563,7 +1563,7 @@ calc_crc32( u32  crc,  u8  *p,  u32  len )
"xorl   %%ebx, %%ebx\n"
"movl   %2, %%esi\n" 
"movl   %3, %%ecx\n" 
-   "movl   $crc32tab, %%edi\n"
+   "movl   $sbni_crc32tab, %%edi\n"
"shrl   $2, %%ecx\n"
"jz 1f\n"
 
@@ -1645,7 +1645,7 @@ calc_crc32( u32  crc,  u8  *p,  u32  len )
 #endif /* ASM_CRC */
 
 
-static u32  crc32tab[] __attribute__ ((aligned(8))) = {
+__visible u32  sbni_crc32tab[] __attribute__ ((aligned(8))) = {
0xD202EF8D,  0xA505DF1B,  0x3C0C8EA1,  0x4B0BBE37,
0xD56F2B94,  0xA2681B02,  0x3B614AB8,  0x4C667A2E,
0xDCD967BF,  0xABDE5729,  0x32D70693,  0x45D03605,
diff --git a/drivers/net/wan/sbni.h b/drivers/net/wan/sbni.h
index 8426451..7e6d980 100644
--- a/drivers/net/wan/sbni.h
+++ b/drivers/net/wan/sbni.h
@@ -132,7 +132,7 @@ struct sbni_flags {
 /*
  * CRC-32 stuff
  */
-#define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 
0x00FF))
+#define CRC32(c,crc) (sbni_crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 
8) & 0x00FF))
   /* CRC generator 0xEDB88320 */
   /* CRC remainder 0x2144DF1C */
   /* CRC initial value 0x */
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19/74] x86, lto: Add missing asmlinkages and __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

This is an arch/x86 sweep to add asmlinkage or __visible
to all functions accessed by assembler code. A lot of
functions already had it, but not all.

This is needed for the LTO kernel so that these functions are
not optimized away.

I used asmlinkage for functions without arguments, and __visible
for functions with. This prevents any problems on x86-32 with
asmlinkage changing the calling convention to regparm(0)

I kept it all in a single patch for now. Please let me know
if you want it split up.

Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/hw_irq.h   |  118 +++
 arch/x86/include/asm/irq.h  |2 +-
 arch/x86/include/asm/kprobes.h  |2 +-
 arch/x86/include/asm/setup.h|8 ++-
 arch/x86/include/asm/signal.h   |2 +-
 arch/x86/include/asm/switch_to.h|4 +-
 arch/x86/include/asm/syscalls.h |   22 +++---
 arch/x86/kernel/apic/apic.c |6 +-
 arch/x86/kernel/cpu/mcheck/mce-inject.c |1 +
 arch/x86/kernel/head32.c|2 +-
 arch/x86/kernel/head64.c|2 +-
 arch/x86/kernel/ioport.c|2 +-
 arch/x86/kernel/irq.c   |4 +-
 arch/x86/kernel/irq_work.c  |2 +-
 arch/x86/kernel/kprobes.c   |2 +-
 arch/x86/kernel/machine_kexec_32.c  |2 +-
 arch/x86/kernel/process.c   |   10 ++--
 arch/x86/kernel/process_32.c|2 +-
 arch/x86/kernel/process_64.c|2 +-
 arch/x86/kernel/signal.c|8 +-
 arch/x86/kernel/smp.c   |6 +-
 arch/x86/kernel/syscall_64.c|2 +-
 arch/x86/kernel/vm86_32.c   |3 +-
 arch/x86/lib/usercopy_64.c  |2 +-
 24 files changed, 108 insertions(+), 108 deletions(-)

diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index eb92a6e..a7cd10e 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -26,55 +26,55 @@
 #include 
 
 /* Interrupt handlers registered during init_IRQ */
-extern void apic_timer_interrupt(void);
-extern void x86_platform_ipi(void);
-extern void error_interrupt(void);
-extern void irq_work_interrupt(void);
-
-extern void spurious_interrupt(void);
-extern void thermal_interrupt(void);
-extern void reschedule_interrupt(void);
-
-extern void invalidate_interrupt(void);
-extern void invalidate_interrupt0(void);
-extern void invalidate_interrupt1(void);
-extern void invalidate_interrupt2(void);
-extern void invalidate_interrupt3(void);
-extern void invalidate_interrupt4(void);
-extern void invalidate_interrupt5(void);
-extern void invalidate_interrupt6(void);
-extern void invalidate_interrupt7(void);
-extern void invalidate_interrupt8(void);
-extern void invalidate_interrupt9(void);
-extern void invalidate_interrupt10(void);
-extern void invalidate_interrupt11(void);
-extern void invalidate_interrupt12(void);
-extern void invalidate_interrupt13(void);
-extern void invalidate_interrupt14(void);
-extern void invalidate_interrupt15(void);
-extern void invalidate_interrupt16(void);
-extern void invalidate_interrupt17(void);
-extern void invalidate_interrupt18(void);
-extern void invalidate_interrupt19(void);
-extern void invalidate_interrupt20(void);
-extern void invalidate_interrupt21(void);
-extern void invalidate_interrupt22(void);
-extern void invalidate_interrupt23(void);
-extern void invalidate_interrupt24(void);
-extern void invalidate_interrupt25(void);
-extern void invalidate_interrupt26(void);
-extern void invalidate_interrupt27(void);
-extern void invalidate_interrupt28(void);
-extern void invalidate_interrupt29(void);
-extern void invalidate_interrupt30(void);
-extern void invalidate_interrupt31(void);
-
-extern void irq_move_cleanup_interrupt(void);
-extern void reboot_interrupt(void);
-extern void threshold_interrupt(void);
-
-extern void call_function_interrupt(void);
-extern void call_function_single_interrupt(void);
+extern asmlinkage void apic_timer_interrupt(void);
+extern asmlinkage void x86_platform_ipi(void);
+extern asmlinkage void error_interrupt(void);
+extern asmlinkage void irq_work_interrupt(void);
+
+extern asmlinkage void spurious_interrupt(void);
+extern asmlinkage void thermal_interrupt(void);
+extern asmlinkage void reschedule_interrupt(void);
+
+extern asmlinkage void invalidate_interrupt(void);
+extern asmlinkage void invalidate_interrupt0(void);
+extern asmlinkage void invalidate_interrupt1(void);
+extern asmlinkage void invalidate_interrupt2(void);
+extern asmlinkage void invalidate_interrupt3(void);
+extern asmlinkage void invalidate_interrupt4(void);
+extern asmlinkage void invalidate_interrupt5(void);
+extern asmlinkage void invalidate_interrupt6(void);
+extern asmlinkage void invalidate_interrupt7(void);
+extern asmlinkage void invalidate_interrupt8(void);
+extern asmlinkage void invalidate_interrupt9(void);
+extern asmlinkage 

[PATCH 20/74] x86, lto: Change dotraplinkage into __visible on 32bit

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Mark 32bit dotraplinkage functions as __visible for LTO.
64bit already is using asmlinkage which includes it.

Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/traps.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
index 88eae2a..cc67b3f 100644
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -7,7 +7,7 @@
 #include/* TRAP_TRACE, ... */
 
 #ifdef CONFIG_X86_32
-#define dotraplinkage
+#define dotraplinkage __visible
 #else
 #define dotraplinkage asmlinkage
 #endif
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 27/74] lto: Mark EXPORT_SYMBOL symbols __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 include/linux/export.h |   14 --
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/export.h b/include/linux/export.h
index 696c0f4..784617e 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -47,7 +47,7 @@ extern struct module __this_module;
 
 /* For every exported symbol, place a struct in the __ksymtab section */
 #define __EXPORT_SYMBOL(sym, sec)  \
-   extern typeof(sym) sym; \
+   extern typeof(sym) sym __visible;   \
__CRC_SYMBOL(sym, sec)  \
static const char __kstrtab_##sym[] \
__attribute__((section("__ksymtab_strings"), aligned(1))) \
@@ -78,11 +78,13 @@ extern struct module __this_module;
 
 #else /* !CONFIG_MODULES... */
 
-#define EXPORT_SYMBOL(sym)
-#define EXPORT_SYMBOL_GPL(sym)
-#define EXPORT_SYMBOL_GPL_FUTURE(sym)
-#define EXPORT_UNUSED_SYMBOL(sym)
-#define EXPORT_UNUSED_SYMBOL_GPL(sym)
+/* Even without modules keep the __visible side effect */
+
+#define EXPORT_SYMBOL(sym) extern typeof(sym) sym __visible
+#define EXPORT_SYMBOL_GPL(sym) extern typeof(sym) sym __visible
+#define EXPORT_SYMBOL_GPL_FUTURE(sym) extern typeof(sym) sym __visible
+#define EXPORT_UNUSED_SYMBOL(sym) extern typeof(sym) sym __visible
+#define EXPORT_UNUSED_SYMBOL_GPL(sym) extern typeof(sym) sym __visible
 
 #endif /* CONFIG_MODULES */
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 44/74] lto: Mark functions used by the vsyscall init code visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The vsyscall code is compiled without LTO. This also includes
its init function. The function which are called by it have
to be visible, otherwise they could be optimized away

Signed-off-by: Andi Kleen 
---
 drivers/char/random.c |2 +-
 include/linux/mm.h|1 +
 mm/vmalloc.c  |2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index b86eae9..33c8fe5 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1450,7 +1450,7 @@ late_initcall(random_int_secret_init);
  * depleting entropy is too high
  */
 static DEFINE_PER_CPU(__u32 [MD5_DIGEST_WORDS], get_random_int_hash);
-unsigned int get_random_int(void)
+__visible unsigned int get_random_int(void)
 {
__u32 *hash;
unsigned int ret;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 311be90..d3ca155 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1413,6 +1413,7 @@ extern void set_mm_exe_file(struct mm_struct *mm, struct 
file *new_exe_file);
 extern struct file *get_mm_exe_file(struct mm_struct *mm);
 
 extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
+__visible
 extern int install_special_mapping(struct mm_struct *mm,
   unsigned long addr, unsigned long len,
   unsigned long flags, struct page **pages);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 2bb90b1..286ea0c 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1558,7 +1558,7 @@ EXPORT_SYMBOL(vunmap);
  * Maps @count pages from @pages into contiguous kernel virtual
  * space.
  */
-void *vmap(struct page **pages, unsigned int count,
+__visible void *vmap(struct page **pages, unsigned int count,
unsigned long flags, pgprot_t prot)
 {
struct vm_struct *area;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 59/74] lto: Handle LTO common symbols in module loader

2012-08-18 Thread Andi Kleen
From: Joe Mario 

Here is the workaround I made for having the kernel not reject modules
built with -flto.  The clean solution would be to get the compiler to not
emit the symbol.  Or if it has to emit the symbol, then emit it as
initialized data but put it into a comdat/linkonce section.

Minor tweaks by AK over Joe's patch.

Cc: ru...@rustcorp.com.au
Signed-off-by: Andi Kleen 
---
 kernel/module.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index c00565a..2cbbae3 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1904,6 +1904,10 @@ static int simplify_symbols(struct module *mod, const 
struct load_info *info)
 
switch (sym[i].st_shndx) {
case SHN_COMMON:
+   /* Ignore common symbols */
+   if (!strncmp(name, "__gnu_lto", 9))
+   break;
+
/* We compiled with -fno-common.  These are not
   supposed to happen.  */
pr_debug("Common symbol: %s\n", name);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 39/74] x86, lto: Mark vdso variables __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/vvar.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/vvar.h b/arch/x86/include/asm/vvar.h
index de656ac..d76ac40 100644
--- a/arch/x86/include/asm/vvar.h
+++ b/arch/x86/include/asm/vvar.h
@@ -35,7 +35,7 @@
 
 #define DEFINE_VVAR(type, name)
\
type name   \
-   __attribute__((section(".vvar_" #name), aligned(16)))
+   __attribute__((section(".vvar_" #name), aligned(16))) __visible
 
 #define VVAR(name) (*vvaraddr_ ## name)
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 50/74] x86, lto: Make empty_zero_page __visible for LTO

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/pgtable.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 49afb3f..72b24ab 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -22,7 +22,8 @@
  * ZERO_PAGE is a global shared page that is always zero: used
  * for zero-mapped memory areas etc..
  */
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
+extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]
+   __visible;
 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
 
 extern spinlock_t pgd_lock;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/74] Add __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

gcc 4.6+ has support for a externally_visible attribute, that prevents
the optimizer from optimizing unused symbols away. Add a __visible macro
to use it with that compiler version or later.

Signed-off-by: Andi Kleen 
---
 include/linux/compiler-gcc4.h |7 +++
 include/linux/compiler.h  |4 
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 2f40791..934bc34 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -49,6 +49,13 @@
 #endif
 #endif
 
+#if __GNUC_MINOR__ >= 6
+/*
+ * Tell the optimizer that something else uses this function or variable.
+ */
+#define __visible __attribute__((externally_visible))
+#endif
+
 #if __GNUC_MINOR__ > 0
 #define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
 #endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 923d093..f430e41 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -278,6 +278,10 @@ void ftrace_likely_update(struct ftrace_branch_data *f, 
int val, int expect);
 # define __section(S) __attribute__ ((__section__(#S)))
 #endif
 
+#ifndef __visible
+#define __visible
+#endif
+
 /* Are two types/vars the same type (ignoring qualifiers)? */
 #ifndef __same_type
 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 61/74] Kbuild, lto: Drop .number postfixes in modpost

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

LTO turns all global symbols effectively into statics. This
has the side effect that they all have a .NUMBER postfix to make
them unique. In modpost drop this postfix because it confuses
it.

Signed-off-by: Andi Kleen 
---
 scripts/mod/modpost.c |   15 ++-
 scripts/mod/modpost.h |2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index c797e95..ccd34ff 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1696,6 +1696,19 @@ static void check_sec_ref(struct module *mod, const char 
*modname,
}
 }
 
+static char *remove_dot(char *s)
+{
+   char *end;
+   int n = strcspn(s, ".");
+
+   if (n > 0 && s[n] != 0) {
+   strtoul(s + n + 1, , 10);
+   if  (end > s + n + 1 && (*end == '.' || *end == 0))
+   s[n] = 0;
+   }
+   return s;
+}
+
 static void read_symbols(char *modname)
 {
const char *symname;
@@ -1734,7 +1747,7 @@ static void read_symbols(char *modname)
}
 
for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
-   symname = info.strtab + sym->st_name;
+   symname = remove_dot(info.strtab + sym->st_name);
 
handle_modversions(mod, , sym, symname);
handle_moddevtable(mod, , sym, symname);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 51207e4..168b43d 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -127,7 +127,7 @@ struct elf_info {
Elf_Section  export_gpl_sec;
Elf_Section  export_unused_gpl_sec;
Elf_Section  export_gpl_future_sec;
-   const char   *strtab;
+   char *strtab;
char *modinfo;
unsigned int modinfo_len;
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 47/74] x86, lto: Fix kprobes for LTO

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

- Make all the external assembler template symbols __visible
- Move the templates inline assembler code into a top level
assembler statement, not inside a function. This avoids it being
optimized away or cloned.

Cc: ana...@in.ibm.com
Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/kprobes.h |8 
 arch/x86/kernel/kprobes-opt.c  |5 +
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
index a967173..fa2d12e 100644
--- a/arch/x86/include/asm/kprobes.h
+++ b/arch/x86/include/asm/kprobes.h
@@ -48,10 +48,10 @@ typedef u8 kprobe_opcode_t;
 #define flush_insn_slot(p) do { } while (0)
 
 /* optinsn template addresses */
-extern kprobe_opcode_t optprobe_template_entry;
-extern kprobe_opcode_t optprobe_template_val;
-extern kprobe_opcode_t optprobe_template_call;
-extern kprobe_opcode_t optprobe_template_end;
+extern __visible kprobe_opcode_t optprobe_template_entry;
+extern __visible kprobe_opcode_t optprobe_template_val;
+extern __visible kprobe_opcode_t optprobe_template_call;
+extern __visible kprobe_opcode_t optprobe_template_end;
 #define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + RELATIVE_ADDR_SIZE)
 #define MAX_OPTINSN_SIZE   \
(((unsigned long)_template_end -   \
diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
index c5e410e..43c34e8 100644
--- a/arch/x86/kernel/kprobes-opt.c
+++ b/arch/x86/kernel/kprobes-opt.c
@@ -88,9 +88,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t 
*addr, unsigned long v
*(unsigned long *)addr = val;
 }
 
-static void __used __kprobes kprobes_optinsn_template_holder(void)
-{
-   asm volatile (
+asm (
".global optprobe_template_entry\n"
"optprobe_template_entry:\n"
 #ifdef CONFIG_X86_64
@@ -129,7 +127,6 @@ static void __used __kprobes 
kprobes_optinsn_template_holder(void)
 #endif
".global optprobe_template_end\n"
"optprobe_template_end:\n");
-}
 
 #define TMPL_MOVE_IDX \
((long)_template_val - (long)_template_entry)
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/74] sections: Add __visible to m68k sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/m68k/include/asm/module.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/m68k/include/asm/module.h b/arch/m68k/include/asm/module.h
index edffe66..15cb110 100644
--- a/arch/m68k/include/asm/module.h
+++ b/arch/m68k/include/asm/module.h
@@ -30,7 +30,7 @@ struct mod_arch_specific {
 
 #endif /* CONFIG_MMU */
 
-extern struct m68k_fixup_info __start_fixup[], __stop_fixup[];
+extern __visible struct m68k_fixup_info __start_fixup[], __stop_fixup[];
 
 struct module;
 extern void module_fixup(struct module *mod, struct m68k_fixup_info *start,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/74] sections: Add __visible to kernel/* sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 kernel/extable.c  |4 ++--
 kernel/ksysfs.c   |4 ++--
 kernel/module.c   |   30 +++---
 kernel/params.c   |6 +++---
 kernel/spinlock.c |2 +-
 5 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/kernel/extable.c b/kernel/extable.c
index fe35a63..2328718 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -32,8 +32,8 @@
  */
 DEFINE_MUTEX(text_mutex);
 
-extern struct exception_table_entry __start___ex_table[];
-extern struct exception_table_entry __stop___ex_table[];
+extern __visible struct exception_table_entry __start___ex_table[];
+extern __visible struct exception_table_entry __stop___ex_table[];
 
 /* Cleared by build time tools if the table is already sorted. */
 u32 __initdata main_extable_sort_needed = 1;
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 4e316e1..627314f 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -144,8 +144,8 @@ KERNEL_ATTR_RO(fscaps);
 /*
  * Make /sys/kernel/notes give the raw contents of our kernel .notes section.
  */
-extern const void __start_notes __attribute__((weak));
-extern const void __stop_notes __attribute__((weak));
+extern __visible const void __start_notes __attribute__((weak));
+extern __visible const void __stop_notes __attribute__((weak));
 #definenotes_size (&__stop_notes - &__start_notes)
 
 static ssize_t notes_read(struct file *filp, struct kobject *kobj,
diff --git a/kernel/module.c b/kernel/module.c
index 4edbd9c..c00565a 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -206,22 +206,22 @@ static void *section_objs(const struct load_info *info,
 }
 
 /* Provided by the linker */
-extern const struct kernel_symbol __start___ksymtab[];
-extern const struct kernel_symbol __stop___ksymtab[];
-extern const struct kernel_symbol __start___ksymtab_gpl[];
-extern const struct kernel_symbol __stop___ksymtab_gpl[];
-extern const struct kernel_symbol __start___ksymtab_gpl_future[];
-extern const struct kernel_symbol __stop___ksymtab_gpl_future[];
-extern const unsigned long __start___kcrctab[];
-extern const unsigned long __start___kcrctab_gpl[];
-extern const unsigned long __start___kcrctab_gpl_future[];
+extern __visible const struct kernel_symbol __start___ksymtab[];
+extern __visible const struct kernel_symbol __stop___ksymtab[];
+extern __visible const struct kernel_symbol __start___ksymtab_gpl[];
+extern __visible const struct kernel_symbol __stop___ksymtab_gpl[];
+extern __visible const struct kernel_symbol __start___ksymtab_gpl_future[];
+extern __visible const struct kernel_symbol __stop___ksymtab_gpl_future[];
+extern __visible const unsigned long __start___kcrctab[];
+extern __visible const unsigned long __start___kcrctab_gpl[];
+extern __visible const unsigned long __start___kcrctab_gpl_future[];
 #ifdef CONFIG_UNUSED_SYMBOLS
-extern const struct kernel_symbol __start___ksymtab_unused[];
-extern const struct kernel_symbol __stop___ksymtab_unused[];
-extern const struct kernel_symbol __start___ksymtab_unused_gpl[];
-extern const struct kernel_symbol __stop___ksymtab_unused_gpl[];
-extern const unsigned long __start___kcrctab_unused[];
-extern const unsigned long __start___kcrctab_unused_gpl[];
+extern __visible const struct kernel_symbol __start___ksymtab_unused[];
+extern __visible const struct kernel_symbol __stop___ksymtab_unused[];
+extern __visible const struct kernel_symbol __start___ksymtab_unused_gpl[];
+extern __visible const struct kernel_symbol __stop___ksymtab_unused_gpl[];
+extern __visible const unsigned long __start___kcrctab_unused[];
+extern __visible const unsigned long __start___kcrctab_unused_gpl[];
 #endif
 
 #ifndef CONFIG_MODVERSIONS
diff --git a/kernel/params.c b/kernel/params.c
index ed35345..c3e61dc 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -503,7 +503,7 @@ EXPORT_SYMBOL(param_ops_string);
 #define to_module_attr(n) container_of(n, struct module_attribute, attr)
 #define to_module_kobject(n) container_of(n, struct module_kobject, kobj)
 
-extern struct kernel_param __start___param[], __stop___param[];
+extern __visible struct kernel_param __start___param[], __stop___param[];
 
 struct param_attribute
 {
@@ -827,8 +827,8 @@ ssize_t __modver_version_show(struct module_attribute 
*mattr,
return sprintf(buf, "%s\n", vattr->version);
 }
 
-extern const struct module_version_attribute *__start___modver[];
-extern const struct module_version_attribute *__stop___modver[];
+extern __visible const struct module_version_attribute *__start___modver[];
+extern __visible const struct module_version_attribute *__stop___modver[];
 
 static void __init version_sysfs_builtin(void)
 {
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index 5cdd806..75439be 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -377,7 +377,7 @@ EXPORT_SYMBOL(_raw_spin_lock_nest_lock);
 notrace int in_lock_functions(unsigned long addr)
 {
/* Linker adds these: start and end of __lockfunc functions */
-

[PATCH 58/74] lto, workaround: Work around LTO compiler problem in atheros driver

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Making these symbols visible works around a gcc 4.7 LTO compiler
problem with missing symbols.

Signed-off-by: Andi Kleen 
---
 .../net/wireless/ath/ath9k/dfs_pattern_detector.c  |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c 
b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
index ea2a6cf..83c579a 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_pattern_detector.c
@@ -51,7 +51,7 @@ struct radar_types {
 }
 
 /* radar types as defined by ETSI EN-301-893 v1.5.1 */
-static const struct radar_detector_specs etsi_radar_ref_types_v15[] = {
+__visible const struct radar_detector_specs etsi_radar_ref_types_v15[] = {
ETSI_PATTERN(0,  0,  1,  700,  700, 1, 18),
ETSI_PATTERN(1,  0,  5,  200, 1000, 1, 10),
ETSI_PATTERN(2,  0, 15,  200, 1600, 1, 15),
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 42/74] lto, raid: disable LTO for the Altivec RAID code

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

It needs special options for a file, which LTO does not support.

XXX: may need some more __visibles

Cc: b...@kernel.crashing.org
Cc: h...@zytor.com
Signed-off-by: Andi Kleen 
---
 lib/raid6/Makefile |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
index de06dfe..55fbafb 100644
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -10,7 +10,7 @@ quiet_cmd_unroll = UNROLL  $@
< $< > $@ || ( rm -f $@ && exit 1 )
 
 ifeq ($(CONFIG_ALTIVEC),y)
-altivec_flags := -maltivec -mabi=altivec
+altivec_flags := -maltivec -mabi=altivec ${DISABLE_LTO}
 endif
 
 targets += int1.c
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/74] sections: Add __visible to init/* sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 init/do_mounts_initrd.c |2 +-
 init/initramfs.c|4 ++--
 init/main.c |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 135959a2..71a625e 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -36,7 +36,7 @@ __setup("noinitrd", no_initrd);
 static int __init do_linuxrc(void *_shell)
 {
static const char *argv[] = { "linuxrc", NULL, };
-   extern const char *envp_init[];
+   extern __visible const char *envp_init[];
const char *shell = _shell;
 
sys_close(old_fd);sys_close(root_fd);
diff --git a/init/initramfs.c b/init/initramfs.c
index 84c6bf1..8a1fd07 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -493,8 +493,8 @@ static int __init retain_initrd_param(char *str)
 }
 __setup("retain_initrd", retain_initrd_param);
 
-extern char __initramfs_start[];
-extern unsigned long __initramfs_size;
+extern __visible char __initramfs_start[];
+extern __visible unsigned long __initramfs_size;
 #include 
 #include 
 
diff --git a/init/main.c b/init/main.c
index e60679d..6438ffd 100644
--- a/init/main.c
+++ b/init/main.c
@@ -470,7 +470,7 @@ static void __init mm_init(void)
 asmlinkage void __init start_kernel(void)
 {
char * command_line;
-   extern const struct kernel_param __start___param[], __stop___param[];
+   extern __visible const struct kernel_param __start___param[], 
__stop___param[];
 
/*
 * Need to run as early as possible, to initialize the
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 34/74] x86, lto, lguest: Fix C functions used by inline assembler

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

- Make the C code used by the paravirt stubs visible
- Since they have to be global now, give them a more unique
name.

Cc: ru...@rustcorp.com.au
Signed-off-by: Andi Kleen 
---
 arch/x86/lguest/boot.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 642d880..dd167d2 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -234,13 +234,13 @@ static void lguest_end_context_switch(struct task_struct 
*next)
  * flags word contains all kind of stuff, but in practice Linux only cares
  * about the interrupt flag.  Our "save_flags()" just returns that.
  */
-static unsigned long save_fl(void)
+asmlinkage unsigned long lguest_save_fl(void)
 {
return lguest_data.irq_enabled;
 }
 
 /* Interrupts go off... */
-static void irq_disable(void)
+asmlinkage void lguest_irq_disable(void)
 {
lguest_data.irq_enabled = 0;
 }
@@ -254,8 +254,8 @@ static void irq_disable(void)
  * PV_CALLEE_SAVE_REGS_THUNK(), which pushes %eax onto the stack, calls the
  * C function, then restores it.
  */
-PV_CALLEE_SAVE_REGS_THUNK(save_fl);
-PV_CALLEE_SAVE_REGS_THUNK(irq_disable);
+PV_CALLEE_SAVE_REGS_THUNK(lguest_save_fl);
+PV_CALLEE_SAVE_REGS_THUNK(lguest_irq_disable);
 /*:*/
 
 /* These are in i386_head.S */
@@ -1285,9 +1285,9 @@ __init void lguest_init(void)
 */
 
/* Interrupt-related operations */
-   pv_irq_ops.save_fl = PV_CALLEE_SAVE(save_fl);
+   pv_irq_ops.save_fl = PV_CALLEE_SAVE(lguest_save_fl);
pv_irq_ops.restore_fl = __PV_IS_CALLEE_SAVE(lg_restore_fl);
-   pv_irq_ops.irq_disable = PV_CALLEE_SAVE(irq_disable);
+   pv_irq_ops.irq_disable = PV_CALLEE_SAVE(lguest_irq_disable);
pv_irq_ops.irq_enable = __PV_IS_CALLEE_SAVE(lg_irq_enable);
pv_irq_ops.safe_halt = lguest_safe_halt;
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 73/74] lto, module: Warn about modules that are not fully LTOed

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

When __gnu_lto_* is present that means that the module hasn't run with
LTO yet.

Cc: ru...@rustcorp.com.au
Signed-off-by: Andi Kleen 
---
 kernel/module.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 2cbbae3..a8a29c4 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1905,8 +1905,11 @@ static int simplify_symbols(struct module *mod, const 
struct load_info *info)
switch (sym[i].st_shndx) {
case SHN_COMMON:
/* Ignore common symbols */
-   if (!strncmp(name, "__gnu_lto", 9))
+   if (!strncmp(name, "__gnu_lto", 9)) {
+   printk("%s: module not link time optimized\n",
+  mod->name);
break;
+   }
 
/* We compiled with -fno-common.  These are not
   supposed to happen.  */
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 30/74] x86, lto: Fix AMD K6 indirect call check

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The AMD K6 errata check relies on timing a indirect call.
But the way it was written it could be optimized to a direct call.
Force gcc to actually do a indirect call and not just
constant resolve the target address.

Signed-off-by: Andi Kleen 
---
 arch/x86/kernel/cpu/amd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 2c02d92..cb72014 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -116,7 +116,7 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
 */
 
n = K6_BUG_LOOP;
-   f_vide = vide;
+   asm("" : "=r" (f_vide) : "0" (vide));
rdtscl(d);
while (n--)
f_vide();
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/74] sections: Add __visible to sh sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/sh/include/asm/sections.h |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/sh/include/asm/sections.h b/arch/sh/include/asm/sections.h
index 1b61997..e18e132 100644
--- a/arch/sh/include/asm/sections.h
+++ b/arch/sh/include/asm/sections.h
@@ -3,10 +3,10 @@
 
 #include 
 
-extern long __nosave_begin, __nosave_end;
-extern long __machvec_start, __machvec_end;
-extern char __uncached_start, __uncached_end;
-extern char __start_eh_frame[], __stop_eh_frame[];
+extern __visible long __nosave_begin, __nosave_end;
+extern __visible long __machvec_start, __machvec_end;
+extern __visible char __uncached_start, __uncached_end;
+extern __visible char __start_eh_frame[], __stop_eh_frame[];
 
 #endif /* __ASM_SH_SECTIONS_H */
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/74] sections: Add __visible to jump_label sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 include/linux/jump_label.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 0976fc4..a39e8e3 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -106,8 +106,8 @@ static __always_inline bool static_key_true(struct 
static_key *key)
return !static_key_false(key);
 }
 
-extern struct jump_entry __start___jump_table[];
-extern struct jump_entry __stop___jump_table[];
+extern __visible struct jump_entry __start___jump_table[];
+extern __visible struct jump_entry __stop___jump_table[];
 
 extern void jump_label_init(void);
 extern void jump_label_lock(void);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 29/74] x86, lto: Make amd.c vide visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

A label declared in inline assembler has to be visible

Signed-off-by: Andi Kleen 
---
 arch/x86/kernel/cpu/amd.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 9d92e19..2c02d92 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -67,8 +67,8 @@ static inline int wrmsrl_amd_safe(unsigned msr, unsigned long 
long val)
  * performance at the same time..
  */
 
-extern void vide(void);
-__asm__(".align 4\nvide: ret");
+extern __visible void vide(void);
+__asm__(".globl vide\n\t.align 4\nvide: ret");
 
 static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
 {
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 24/74] lto: Mark do_exit asmlinkage

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

... since it can be called from assembler code

Signed-off-by: Andi Kleen 
---
 include/linux/kernel.h |2 +-
 kernel/exit.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 6043821..73a1a54 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -209,7 +209,7 @@ extern void oops_enter(void);
 extern void oops_exit(void);
 void print_oops_end_marker(void);
 extern int oops_may_print(void);
-void do_exit(long error_code)
+asmlinkage void do_exit(long error_code)
__noreturn;
 void complete_and_exit(struct completion *, long)
__noreturn;
diff --git a/kernel/exit.c b/kernel/exit.c
index f65345f..7de9a3e 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -902,7 +902,7 @@ static void check_stack_usage(void)
 static inline void check_stack_usage(void) {}
 #endif
 
-void do_exit(long code)
+asmlinkage void do_exit(long code)
 {
struct task_struct *tsk = current;
int group_dead;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 52/74] x86, lto, paravirt: Don't rely on local assembler labels

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The paravirt patching code assumes that it can reference a
local assembler label between two different top level assembler
statements. This does not work with some experimental gcc builds,
where the assembler code may end up in different assembler files.

Replace it with extern / global /asm linkage labels.

This also removes one redundant copy of the macro.

Cc: jer...@goop.org
Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/paravirt_types.h |9 +
 arch/x86/kernel/paravirt.c|5 -
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/x86/include/asm/paravirt_types.h 
b/arch/x86/include/asm/paravirt_types.h
index 4f262bc..6a464ba 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -385,10 +385,11 @@ extern struct pv_lock_ops pv_lock_ops;
_paravirt_alt(insn_string, "%c[paravirt_typenum]", 
"%c[paravirt_clobber]")
 
 /* Simple instruction patching code. */
-#define DEF_NATIVE(ops, name, code)\
-   extern const char start_##ops##_##name[] __visible, \
- end_##ops##_##name[] __visible;   \
-   asm("start_" #ops "_" #name ": " code "; end_" #ops "_" #name ":")
+#define NATIVE_LABEL(a,x,b) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t"
+
+#define DEF_NATIVE(ops, name, code)\
+   __visible extern const char start_##ops##_##name[], 
end_##ops##_##name[];   \
+   asm(NATIVE_LABEL("start_", ops, name) code NATIVE_LABEL("end_", ops, 
name))
 
 unsigned paravirt_patch_nop(void);
 unsigned paravirt_patch_ident_32(void *insnbuf, unsigned len);
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 17fff18..947255e 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -62,11 +62,6 @@ void __init default_banner(void)
   pv_info.name);
 }
 
-/* Simple instruction patching code. */
-#define DEF_NATIVE(ops, name, code)\
-   extern const char start_##ops##_##name[], end_##ops##_##name[]; \
-   asm("start_" #ops "_" #name ": " code "; end_" #ops "_" #name ":")
-
 /* Undefined instruction for dealing with missing ops pointers. */
 static const unsigned char ud2a[] = { 0x0f, 0x0b };
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/74] sections: Add __visible to lib/* sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 lib/bug.c   |2 +-
 lib/dynamic_debug.c |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/bug.c b/lib/bug.c
index a28c141..f81e1a6 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -43,7 +43,7 @@
 #include 
 #include 
 
-extern const struct bug_entry __start___bug_table[], __stop___bug_table[];
+extern __visible const struct bug_entry __start___bug_table[], 
__stop___bug_table[];
 
 static inline unsigned long bug_addr(const struct bug_entry *bug)
 {
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 7ca29a0..1760a71 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -34,8 +34,8 @@
 #include 
 #include 
 
-extern struct _ddebug __start___verbose[];
-extern struct _ddebug __stop___verbose[];
+extern __visible struct _ddebug __start___verbose[];
+extern __visible struct _ddebug __stop___verbose[];
 
 struct ddebug_table {
struct list_head link;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 53/74] x86, lto, paravirt: Make paravirt thunks global

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The paravirt thunks use a hack of using a static reference to a static
function to reference that function from the top level statement.

This assumes that gcc always generates static function names in a specific
format, which is not necessarily true.

Simply make these functions global and asmlinkage. This way the
static __used variables are not needed and everything works.

Changed in paravirt and in all users (Xen and vsmp)

Cc: jer...@goop.org
Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/paravirt.h |2 +-
 arch/x86/kernel/vsmp_64.c   |8 
 arch/x86/xen/irq.c  |8 
 arch/x86/xen/mmu.c  |   16 
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index a0facf3..cc733a6 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -804,9 +804,9 @@ static __always_inline void arch_spin_unlock(struct 
arch_spinlock *lock)
  */
 #define PV_CALLEE_SAVE_REGS_THUNK(func)
\
extern typeof(func) __raw_callee_save_##func;   \
-   static void *__##func##__ __used = func;\
\
asm(".pushsection .text;"   \
+   ".globl __raw_callee_save_" #func " ; " \
"__raw_callee_save_" #func ": " \
PV_SAVE_ALL_CALLER_REGS \
"call " #func ";"   \
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index 992f890..f393d6d 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -33,7 +33,7 @@
  * and vice versa.
  */
 
-static unsigned long vsmp_save_fl(void)
+asmlinkage unsigned long vsmp_save_fl(void)
 {
unsigned long flags = native_save_fl();
 
@@ -43,7 +43,7 @@ static unsigned long vsmp_save_fl(void)
 }
 PV_CALLEE_SAVE_REGS_THUNK(vsmp_save_fl);
 
-static void vsmp_restore_fl(unsigned long flags)
+asmlinkage void vsmp_restore_fl(unsigned long flags)
 {
if (flags & X86_EFLAGS_IF)
flags &= ~X86_EFLAGS_AC;
@@ -53,7 +53,7 @@ static void vsmp_restore_fl(unsigned long flags)
 }
 PV_CALLEE_SAVE_REGS_THUNK(vsmp_restore_fl);
 
-static void vsmp_irq_disable(void)
+asmlinkage void vsmp_irq_disable(void)
 {
unsigned long flags = native_save_fl();
 
@@ -61,7 +61,7 @@ static void vsmp_irq_disable(void)
 }
 PV_CALLEE_SAVE_REGS_THUNK(vsmp_irq_disable);
 
-static void vsmp_irq_enable(void)
+asmlinkage void vsmp_irq_enable(void)
 {
unsigned long flags = native_save_fl();
 
diff --git a/arch/x86/xen/irq.c b/arch/x86/xen/irq.c
index 1573376..3dd8831 100644
--- a/arch/x86/xen/irq.c
+++ b/arch/x86/xen/irq.c
@@ -21,7 +21,7 @@ void xen_force_evtchn_callback(void)
(void)HYPERVISOR_xen_version(0, NULL);
 }
 
-static unsigned long xen_save_fl(void)
+asmlinkage unsigned long xen_save_fl(void)
 {
struct vcpu_info *vcpu;
unsigned long flags;
@@ -39,7 +39,7 @@ static unsigned long xen_save_fl(void)
 }
 PV_CALLEE_SAVE_REGS_THUNK(xen_save_fl);
 
-static void xen_restore_fl(unsigned long flags)
+asmlinkage void xen_restore_fl(unsigned long flags)
 {
struct vcpu_info *vcpu;
 
@@ -66,7 +66,7 @@ static void xen_restore_fl(unsigned long flags)
 }
 PV_CALLEE_SAVE_REGS_THUNK(xen_restore_fl);
 
-static void xen_irq_disable(void)
+asmlinkage void xen_irq_disable(void)
 {
/* There's a one instruction preempt window here.  We need to
   make sure we're don't switch CPUs between getting the vcpu
@@ -77,7 +77,7 @@ static void xen_irq_disable(void)
 }
 PV_CALLEE_SAVE_REGS_THUNK(xen_irq_disable);
 
-static void xen_irq_enable(void)
+asmlinkage void xen_irq_enable(void)
 {
struct vcpu_info *vcpu;
 
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index b65a761..9f82443 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -429,7 +429,7 @@ static pteval_t iomap_pte(pteval_t val)
return val;
 }
 
-static pteval_t xen_pte_val(pte_t pte)
+asmlinkage pteval_t xen_pte_val(pte_t pte)
 {
pteval_t pteval = pte.pte;
 #if 0
@@ -446,7 +446,7 @@ static pteval_t xen_pte_val(pte_t pte)
 }
 PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val);
 
-static pgdval_t xen_pgd_val(pgd_t pgd)
+asmlinkage pgdval_t xen_pgd_val(pgd_t pgd)
 {
return pte_mfn_to_pfn(pgd.pgd);
 }
@@ -477,7 +477,7 @@ void xen_set_pat(u64 pat)
WARN_ON(pat != 0x0007010600070106ull);
 }
 
-static pte_t xen_make_pte(pteval_t pte)
+asmlinkage pte_t xen_make_pte(pteval_t pte)
 {
phys_addr_t addr = (pte & PTE_PFN_MASK);
 #if 0
@@ -512,14 +512,14 @@ static pte_t xen_make_pte(pteval_t pte)
 }
 PV_CALLEE_SAVE_REGS_THUNK(xen_make_pte);
 
-static pgd_t xen_make_pgd(pgdval_t pgd)
+asmlinkage pgd_t 

[PATCH 26/74] lto, sound: Fix export symbols for !CONFIG_MODULES

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The new LTO EXPORT_SYMBOL references symbols even without CONFIG_MODULES.
Since these functions are macros in this case this doesn't work.
Add a ifdef to fix the build.

Cc: ti...@suse.de
Signed-off-by: Andi Kleen 
---
 sound/core/seq/seq_device.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
index 5cf8d65..60e8fc1 100644
--- a/sound/core/seq/seq_device.c
+++ b/sound/core/seq/seq_device.c
@@ -569,5 +569,7 @@ EXPORT_SYMBOL(snd_seq_device_load_drivers);
 EXPORT_SYMBOL(snd_seq_device_new);
 EXPORT_SYMBOL(snd_seq_device_register_driver);
 EXPORT_SYMBOL(snd_seq_device_unregister_driver);
+#ifdef CONFIG_MODULES
 EXPORT_SYMBOL(snd_seq_autoload_lock);
 EXPORT_SYMBOL(snd_seq_autoload_unlock);
+#endif
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 21/74] lto: Make lockdep_sys_exit asmlinkage

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

lockdep_sys_exit can be called from assembler code, so make it
asmlinkage

Signed-off-by: Andi Kleen 
---
 include/linux/lockdep.h |2 +-
 kernel/lockdep.c|2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 00e4637..f37a847 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -265,7 +265,7 @@ extern void lockdep_info(void);
 extern void lockdep_reset(void);
 extern void lockdep_reset_lock(struct lockdep_map *lock);
 extern void lockdep_free_key_range(void *start, unsigned long size);
-extern void lockdep_sys_exit(void);
+extern asmlinkage void lockdep_sys_exit(void);
 
 extern void lockdep_off(void);
 extern void lockdep_on(void);
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index ea9ee45..ef76308 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -4142,7 +4142,7 @@ void debug_show_held_locks(struct task_struct *task)
 }
 EXPORT_SYMBOL_GPL(debug_show_held_locks);
 
-void lockdep_sys_exit(void)
+asmlinkage void lockdep_sys_exit(void)
 {
struct task_struct *curr = current;
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 28/74] lto: Make ksymtab and kcrctab symbols and __this_module __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Make the ksymtab symbols for EXPORT_SYMBOL visible.
This prevents the LTO compiler from adding a .NUMBER prefix,
which avoids various problems in later export processing.

Signed-off-by: Andi Kleen 
---
 include/linux/export.h |4 ++--
 scripts/mod/modpost.c  |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/export.h b/include/linux/export.h
index 784617e..77a3e8c 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -36,7 +36,7 @@ extern struct module __this_module;
 /* Mark the CRC weak since genksyms apparently decides not to
  * generate a checksums for some symbols */
 #define __CRC_SYMBOL(sym, sec) \
-   extern void *__crc_##sym __attribute__((weak)); \
+   extern __visible void *__crc_##sym __attribute__((weak));   
\
static const unsigned long __kcrctab_##sym  \
__used  \
__attribute__((section("___kcrctab" sec "+" #sym), unused)) \
@@ -52,7 +52,7 @@ extern struct module __this_module;
static const char __kstrtab_##sym[] \
__attribute__((section("__ksymtab_strings"), aligned(1))) \
= MODULE_SYMBOL_PREFIX #sym;\
-   static const struct kernel_symbol __ksymtab_##sym   \
+   __visible const struct kernel_symbol __ksymtab_##sym\
__used  \
__attribute__((section("___ksymtab" sec "+" #sym), unused)) \
= { (unsigned long), __kstrtab_##sym }
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 68e9f5e..c797e95 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1862,7 +1862,7 @@ static void add_header(struct buffer *b, struct module 
*mod)
buf_printf(b, "\n");
buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
buf_printf(b, "\n");
-   buf_printf(b, "struct module __this_module\n");
+   buf_printf(b, "__visible struct module __this_module\n");
buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) 
= {\n");
buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
if (mod->has_init)
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 37/74] lto, KVM: Don't assume asm statements end up in the same assembler file

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The VMX code references a local assembler label between two inline
assembler statements. This assumes they both end up in the same
assembler files. In some experimental builds of gcc this is not
necessarily true, causing linker failures.

Replace the local label reference with a more traditional asmlinkage
extern.

This also eliminates one assembler statement and
generates a bit better code on 64bit: the compiler can
use a RIP relative LEA instead of a movabs, saving
a few bytes.

Cc: a...@redhat.com
Signed-off-by: Andi Kleen 
---
 arch/x86/kvm/vmx.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c00f03d..2fe1de3 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3718,6 +3718,8 @@ static void vmx_disable_intercept_for_msr(u32 msr, bool 
longmode_only)
__vmx_disable_intercept_for_msr(vmx_msr_bitmap_longmode, msr);
 }
 
+extern __visible unsigned long kvm_vmx_return;
+
 /*
  * Set up the vmcs's constant host-state fields, i.e., host-state fields that
  * will not change in the lifetime of the guest.
@@ -3753,8 +3755,7 @@ static void vmx_set_constant_host_state(void)
native_store_idt();
vmcs_writel(HOST_IDTR_BASE, dt.address);   /* 22.2.4 */
 
-   asm("mov $.Lkvm_vmx_return, %0" : "=r"(tmpl));
-   vmcs_writel(HOST_RIP, tmpl); /* 22.2.5 */
+   vmcs_writel(HOST_RIP, (unsigned long)_vmx_return); /* 22.2.5 */
 
rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
@@ -6305,9 +6306,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
/* Enter guest mode */
"jne .Llaunched \n\t"
__ex(ASM_VMX_VMLAUNCH) "\n\t"
-   "jmp .Lkvm_vmx_return \n\t"
+   "jmp kvm_vmx_return \n\t"
".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t"
-   ".Lkvm_vmx_return: "
+   ".globl kvm_vmx_return\n"
+   "kvm_vmx_return: "
/* Save guest registers, load host registers, keep flags */
"mov %0, %c[wordsize](%%"R"sp) \n\t"
"pop %0 \n\t"
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 15/74] sections: Add __visible to kernel/trace/* sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 kernel/trace/ftrace.c |4 ++--
 kernel/trace/trace.h  |4 ++--
 kernel/trace/trace_branch.c   |8 
 kernel/trace/trace_events.c   |4 ++--
 kernel/trace/trace_syscalls.c |4 ++--
 kernel/tracepoint.c   |4 ++--
 6 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b4f20fb..5028bd3 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3866,8 +3866,8 @@ struct notifier_block ftrace_module_nb = {
.priority = 0,
 };
 
-extern unsigned long __start_mcount_loc[];
-extern unsigned long __stop_mcount_loc[];
+extern __visible unsigned long __start_mcount_loc[];
+extern __visible unsigned long __stop_mcount_loc[];
 
 void __init ftrace_init(void)
 {
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 55e1f7f..8c063e7 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -836,8 +836,8 @@ extern void trace_event_enable_cmd_record(bool enable);
 extern struct mutex event_mutex;
 extern struct list_head ftrace_events;
 
-extern const char *__start___trace_bprintk_fmt[];
-extern const char *__stop___trace_bprintk_fmt[];
+extern __visible const char *__start___trace_bprintk_fmt[];
+extern __visible const char *__stop___trace_bprintk_fmt[];
 
 void trace_printk_init_buffers(void);
 
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index 8d3538b..5be6217 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -226,8 +226,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int 
val, int expect)
 }
 EXPORT_SYMBOL(ftrace_likely_update);
 
-extern unsigned long __start_annotated_branch_profile[];
-extern unsigned long __stop_annotated_branch_profile[];
+extern __visible unsigned long __start_annotated_branch_profile[];
+extern __visible unsigned long __stop_annotated_branch_profile[];
 
 static int annotated_branch_stat_headers(struct seq_file *m)
 {
@@ -355,8 +355,8 @@ fs_initcall(init_annotated_branch_stats);
 
 #ifdef CONFIG_PROFILE_ALL_BRANCHES
 
-extern unsigned long __start_branch_profile[];
-extern unsigned long __stop_branch_profile[];
+extern __visible unsigned long __start_branch_profile[];
+extern __visible unsigned long __stop_branch_profile[];
 
 static int all_branch_stat_headers(struct seq_file *m)
 {
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 29111da..325c9f0 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1435,8 +1435,8 @@ static struct notifier_block trace_module_nb = {
.priority = 0,
 };
 
-extern struct ftrace_event_call *__start_ftrace_events[];
-extern struct ftrace_event_call *__stop_ftrace_events[];
+extern __visible struct ftrace_event_call *__start_ftrace_events[];
+extern __visible struct ftrace_event_call *__stop_ftrace_events[];
 
 static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 60e4d78..52f3e15 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -56,8 +56,8 @@ struct ftrace_event_class event_class_syscall_exit = {
.raw_init   = init_syscall_trace,
 };
 
-extern struct syscall_metadata *__start_syscalls_metadata[];
-extern struct syscall_metadata *__stop_syscalls_metadata[];
+extern __visible struct syscall_metadata *__start_syscalls_metadata[];
+extern __visible struct syscall_metadata *__stop_syscalls_metadata[];
 
 static struct syscall_metadata **syscalls_metadata;
 
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index d96ba22..ddae1de 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-extern struct tracepoint * const __start___tracepoints_ptrs[];
-extern struct tracepoint * const __stop___tracepoints_ptrs[];
+extern __visible struct tracepoint * const __start___tracepoints_ptrs[];
+extern __visible struct tracepoint * const __stop___tracepoints_ptrs[];
 
 /* Set to 1 to enable tracepoint debug output */
 static const int tracepoint_debug;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 17/74] lto: Make asmlinkage __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 include/linux/linkage.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index 807f1e5..8d6ff27 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -5,9 +5,9 @@
 #include 
 
 #ifdef __cplusplus
-#define CPP_ASMLINKAGE extern "C"
+#define CPP_ASMLINKAGE extern "C" __visible
 #else
-#define CPP_ASMLINKAGE
+#define CPP_ASMLINKAGE __visible
 #endif
 
 #ifndef asmlinkage
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 69/74] lto: Increase kallsyms max symbol length

2012-08-18 Thread Andi Kleen
From: Joe Mario 

With the added postfixes that LTO adds for local
symbols, the longest name in the kernel overflows
the namebuf[KSYM_NAME_LEN] array by two bytes.  That name is:
__pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt.1488004.672802

Double the max symbol name length.

Signed-off-by: Andi Kleen 
---
 include/linux/kallsyms.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index 6883e19..711a50f 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -9,7 +9,7 @@
 #include 
 #include 
 
-#define KSYM_NAME_LEN 128
+#define KSYM_NAME_LEN 256
 #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1)
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 60/74] lto, Kbuild, bloat-o-meter: fix static detection

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Disable static detection: the static currently drops a lot of useful information
including clones generated by gcc. Drop this. The statics will appear now
without static. prefix.

But remove the LTO .NUMBER postfixes that look ugly

Signed-off-by: Andi Kleen 
---
 scripts/bloat-o-meter |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index 6129020..720cbd2 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -20,8 +20,8 @@ def getsizes(file):
 if type in "tTdDbBrR":
 # strip generated symbols
 if name[:6] == "__mod_": continue
-# function names begin with '.' on 64-bit powerpc
-if "." in name[1:]: name = "static." + name.split(".")[0]
+# statics and some other optimizations adds random .NUMBER 
+name = re.sub(r'\.[0-9]+', '', name) 
 sym[name] = sym.get(name, 0) + int(size, 16)
 return sym
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] writeback: add dirty_ratio_time per bdi variable (NFS write performance)

2012-08-18 Thread Fengguang Wu
On Sat, Aug 18, 2012 at 05:50:02AM -0400, Namjae Jeon wrote:
> From: Namjae Jeon 
> 
> This patch is based on suggestion by Wu Fengguang:
> https://lkml.org/lkml/2011/8/19/19
> 
> kernel has mechanism to do writeback as per dirty_ratio and dirty_background
> ratio. It also maintains per task dirty rate limit to keep balance of
> dirty pages at any given instance by doing bdi bandwidth estimation.
> 
> Kernel also has max_ratio/min_ratio tunables to specify percentage of 
> writecache
> to control per bdi dirty limits and task throtelling.
> 
> However, there might be a usecase where user wants a writeback tuning
> parameter to flush dirty data at desired/tuned time interval.
> 
> dirty_background_time provides an interface where user can tune background
> writeback start time using /sys/block/sda/bdi/dirty_background_time
> 
> dirty_background_time is used alongwith average bdi write bandwidth estimation
> to start background writeback.

Here lies my major concern about dirty_background_time: the write
bandwidth estimation is an _estimation_ and will sure become wildly
wrong in some cases. So the dirty_background_time implementation based
on it will not always work to the user expectations.

One important case is, some users (eg. Dave Chinner) explicitly take
advantage of the existing behavior to quickly create & delete a big
1GB temp file without worrying about triggering unnecessary IOs.

> One of the use case to demonstrate the patch functionality can be
> on NFS setup:-
> We have a NFS setup with ethernet line of 100Mbps, while the USB
> disk is attached to server, which has a local speed of 25MBps. Server
> and client both are arm target boards.
> 
> Now if we perform a write operation over NFS (client to server), as
> per the network speed, data can travel at max speed of 100Mbps. But
> if we check the default write speed of USB hdd over NFS it comes
> around to 8MB/sec, far below the speed of network.
> 
> Reason being is as per the NFS logic, during write operation, initially
> pages are dirtied on NFS client side, then after reaching the dirty
> threshold/writeback limit (or in case of sync) data is actually sent
> to NFS server (so now again pages are dirtied on server side). This
> will be done in COMMIT call from client to server i.e if 100MB of data
> is dirtied and sent then it will take minimum 100MB/10Mbps ~ 8-9 seconds.
> 
> After the data is received, now it will take approx 100/25 ~4 Seconds to
> write the data to USB Hdd on server side. Hence making the overall time
> to write this much of data ~12 seconds, which in practically comes out to
> be near 7 to 8MB/second. After this a COMMIT response will be sent to NFS
> client.
> 
> However we may improve this write performace by making the use of NFS
> server idle time i.e while data is being received from the client,
> simultaneously initiate the writeback thread on server side. So instead
> of waiting for the complete data to come and then start the writeback,
> we can work in parallel while the network is still busy in receiving the
> data. Hence in this way overall performace will be improved.
> 
> If we tune dirty_background_time, we can see there
> is increase in the performace and it comes out to be ~ 11MB/seconds.
> Results are:-
> ==
> Case:1 - Normal setup without any changes
> ./performancetest_arm ./100MB write
> 
>  RecSize  WriteSpeed   RanWriteSpeed
> 
>  10485760  7.93MB/sec   8.11MB/sec
>   1048576  8.21MB/sec   7.80MB/sec
>524288  8.71MB/sec   8.39MB/sec
>262144  8.91MB/sec   7.83MB/sec
>131072  8.91MB/sec   8.95MB/sec
> 65536  8.95MB/sec   8.90MB/sec
> 32768  8.76MB/sec   8.93MB/sec
> 16384  8.78MB/sec   8.67MB/sec
>  8192  8.90MB/sec   8.52MB/sec
>  4096  8.89MB/sec   8.28MB/sec
> 
> Average speed is near 8MB/seconds.
> 
> Case:2 - Modified the dirty_background_time
> ./performancetest_arm ./100MB write
> 
>  RecSize  WriteSpeed   RanWriteSpeed
> 
>  10485760  10.56MB/sec  10.37MB/sec
>   1048576  10.43MB/sec  10.33MB/sec
>524288  10.32MB/sec  10.02MB/sec
>262144  10.52MB/sec  10.19MB/sec
>131072  10.34MB/sec  10.07MB/sec
> 65536  10.31MB/sec  10.06MB/sec
> 32768  10.27MB/sec  10.24MB/sec
> 16384  10.54MB/sec  10.03MB/sec
>  8192  10.41MB/sec  10.38MB/sec
>  4096  10.34MB/sec  10.12MB/sec
> 
> we can see, average write speed is increased to ~10-11MB/sec.
> 

The numbers are impressive! FYI, I tried another NFS specific approach
to avoid big NFS COMMITs, which achieved similar performance gains:

nfs: writeback pages wait queue
https://lkml.org/lkml/2011/10/20/235

Thanks,
Fengguang

> Now to make this working we need to make change in dirty_[wirteback|expire]
> _interval so that flusher threads will be awaken up more early. But if we
> modify these values it will impact the overall system performace, while our
> requirement is to modify 

[PATCH 56/74] lto, workaround: Add workaround for missing LTO symbols in igb

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The gcc 4.7 LTO with -fno-toplevel-reorder sometimes drops data
variables. These show up as undefined symbols at link time.
As a workaround just make a few where it happened visible for now.

There isl nothing wrong with this driver, just a toolchain problem.

Signed-off-by: Andi Kleen 
---
 drivers/net/ethernet/intel/igb/e1000_82575.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c 
b/drivers/net/ethernet/intel/igb/e1000_82575.c
index ba994fb..86b985a 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -2254,7 +2254,8 @@ out:
return ret_val;
 }
 
-static struct e1000_mac_operations e1000_mac_ops_82575 = {
+/* Workaround for LTO bug */
+__visible struct e1000_mac_operations e1000_mac_ops_82575 = {
.init_hw  = igb_init_hw_82575,
.check_for_link   = igb_check_for_link_82575,
.rar_set  = igb_rar_set,
@@ -2262,13 +2263,13 @@ static struct e1000_mac_operations e1000_mac_ops_82575 
= {
.get_speed_and_duplex = igb_get_speed_and_duplex_copper,
 };
 
-static struct e1000_phy_operations e1000_phy_ops_82575 = {
+__visible struct e1000_phy_operations e1000_phy_ops_82575 = {
.acquire  = igb_acquire_phy_82575,
.get_cfg_done = igb_get_cfg_done_82575,
.release  = igb_release_phy_82575,
 };
 
-static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
+__visible struct e1000_nvm_operations e1000_nvm_ops_82575 = {
.acquire  = igb_acquire_nvm_82575,
.read = igb_read_nvm_eerd,
.release  = igb_release_nvm_82575,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 54/74] x86, lto, vdso: Don't duplicate vvar address variables

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Every includer of vvar.h currently gets own static variables
for all the vvar addresses. Generate just one set each for the
main kernel and for the vdso. This saves some data space.

Cc: Andy Lutomirski 
Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/vvar.h|   27 +--
 arch/x86/vdso/vclock_gettime.c |1 +
 arch/x86/vdso/vma.c|1 +
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/vvar.h b/arch/x86/include/asm/vvar.h
index d76ac40..1fd06a8 100644
--- a/arch/x86/include/asm/vvar.h
+++ b/arch/x86/include/asm/vvar.h
@@ -24,27 +24,34 @@
 /* The kernel linker script defines its own magic to put vvars in the
  * right place.
  */
-#define DECLARE_VVAR(offset, type, name) \
-   EMIT_VVAR(name, offset)
+#define DECLARE_VVAR(type, name) \
+   EMIT_VVAR(name, VVAR_OFFSET_ ## name)
+
+#elif defined(__VVAR_ADDR)
+
+#define DECLARE_VVAR(type, name)   \
+   type const * const vvaraddr_ ## name =  \
+   (void *)(VVAR_ADDRESS + (VVAR_OFFSET_ ## name));
 
 #else
 
-#define DECLARE_VVAR(offset, type, name)   \
-   static type const * const vvaraddr_ ## name =   \
-   (void *)(VVAR_ADDRESS + (offset));
+#define DECLARE_VVAR(type, name)   \
+   extern type const * const vvaraddr_ ## name;
 
 #define DEFINE_VVAR(type, name)
\
type name   \
__attribute__((section(".vvar_" #name), aligned(16))) __visible
+#endif
 
 #define VVAR(name) (*vvaraddr_ ## name)
 
-#endif
-
 /* DECLARE_VVAR(offset, type, name) */
 
-DECLARE_VVAR(0, volatile unsigned long, jiffies)
-DECLARE_VVAR(16, int, vgetcpu_mode)
-DECLARE_VVAR(128, struct vsyscall_gtod_data, vsyscall_gtod_data)
+#define VVAR_OFFSET_jiffies 0
+DECLARE_VVAR(volatile unsigned long, jiffies)
+#define VVAR_OFFSET_vgetcpu_mode 16
+DECLARE_VVAR(int, vgetcpu_mode)
+#define VVAR_OFFSET_vsyscall_gtod_data 128
+DECLARE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data)
 
 #undef DECLARE_VVAR
diff --git a/arch/x86/vdso/vclock_gettime.c b/arch/x86/vdso/vclock_gettime.c
index 885eff4..007eac4 100644
--- a/arch/x86/vdso/vclock_gettime.c
+++ b/arch/x86/vdso/vclock_gettime.c
@@ -10,6 +10,7 @@
 
 /* Disable profiling for userspace code: */
 #define DISABLE_BRANCH_PROFILING
+#define __VVAR_ADDR 1
 
 #include 
 #include 
diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
index fe08e2b..4432cfc 100644
--- a/arch/x86/vdso/vma.c
+++ b/arch/x86/vdso/vma.c
@@ -3,6 +3,7 @@
  * Copyright 2007 Andi Kleen, SUSE Labs.
  * Subject to the GPL, v.2
  */
+#define __VVAR_ADDR 1
 #include 
 #include 
 #include 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 65/74] Kbuild, lto: Disable LTO for asm-offsets.c

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The asm-offset.c technique to fish data out of the assembler file
does not work with LTO. Just disable for the asm-offset.c build.

Signed-off-by: Andi Kleen 
---
 scripts/Makefile.build |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index ff1720d..11fa091 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -198,7 +198,7 @@ $(multi-objs-y:.o=.s)   : modname = $(modname-multi)
 $(multi-objs-y:.o=.lst) : modname = $(modname-multi)
 
 quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
-cmd_cc_s_c   = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
+cmd_cc_s_c   = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
 
 $(obj)/%.s: $(src)/%.c FORCE
$(call if_changed_dep,cc_s_c)
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

On a 32bit build gcc 4.7 with LTO decides to clobber the 6th argument on the
stack.  Unfortunately this corrupts the user EBP and leads to later crashes.
For now mark do_futex noinline to prevent this.

I wish there was a generic way to handle this. Seems like a ticking time
bomb problem.

Signed-off-by: Andi Kleen 
---
 kernel/futex.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 3717e7b..48b5a07 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2620,7 +2620,7 @@ void exit_robust_list(struct task_struct *curr)
   curr, pip);
 }
 
-long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
+noinline long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
u32 __user *uaddr2, u32 val2, u32 val3)
 {
int cmd = op & FUTEX_CMD_MASK;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 57/74] lto, workaround: Add workaround for LTO build problem in pvrusb2-audio

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Making this visible fixes some missing symbols with gcc 4.7 LTO.
This is a workaround for a compiler problem.

Signed-off-by: Andi Kleen 
---
 drivers/media/video/pvrusb2/pvrusb2-audio.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.c 
b/drivers/media/video/pvrusb2/pvrusb2-audio.c
index cc06d5e..aaa6420 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-audio.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-audio.c
@@ -32,7 +32,7 @@ struct routing_scheme {
unsigned int cnt;
 };
 
-static const int routing_scheme0[] = {
+__visible const int pvrusb2_routing_scheme0[] = {
[PVR2_CVAL_INPUT_TV]= MSP_INPUT_DEFAULT,
[PVR2_CVAL_INPUT_RADIO] = MSP_INPUT(MSP_IN_SCART2,
MSP_IN_TUNER1,
@@ -49,8 +49,8 @@ static const int routing_scheme0[] = {
 };
 
 static const struct routing_scheme routing_def0 = {
-   .def = routing_scheme0,
-   .cnt = ARRAY_SIZE(routing_scheme0),
+   .def = pvrusb2_routing_scheme0,
+   .cnt = ARRAY_SIZE(pvrusb2_routing_scheme0),
 };
 
 static const struct routing_scheme *routing_schemes[] = {
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 55/74] lto, workaround: Add workaround for initcall reordering

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Work around a LTO gcc problem: when there is no reference to a variable
in a module it will be moved to the end of the program. This causes
reordering of initcalls which the kernel does not like.
Add a dummy reference function to avoid this. The function is
deleted by the linker.

This replaces a previous much slower workaround.

Thanks to Honza Hubicka for suggesting this technique.

Signed-off-by: Andi Kleen 
---
 include/linux/init.h |   20 +++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index c2f06b3..e425800 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -176,6 +176,23 @@ extern bool initcall_debug;
 
 #ifndef __ASSEMBLY__
 
+#ifdef CONFIG_LTO
+/* Work around a LTO gcc problem: when there is no reference to a variable
+ * in a module it will be moved to the end of the program. This causes
+ * reordering of initcalls which the kernel does not like.
+ * Add a dummy reference function to avoid this. The function is 
+ * deleted by the linker.
+ */
+#define LTO_REFERENCE_INITCALL(x) \
+   ; /* yes this is needed */  \
+   static __used __exit void *reference_##x(void)  \
+   {   \
+   return   \
+   }
+#else
+#define LTO_REFERENCE_INITCALL(x)
+#endif
+
 /* initcalls are now grouped by functionality into separate 
  * subsections. Ordering inside the subsections is determined
  * by link order. 
@@ -188,7 +205,8 @@ extern bool initcall_debug;
 
 #define __define_initcall(level,fn,id) \
static initcall_t __initcall_##fn##id __used \
-   __attribute__((__section__(".initcall" level ".init"))) = fn
+   __attribute__((__section__(".initcall" level ".init"))) = fn \
+   LTO_REFERENCE_INITCALL(__initcall_##fn##id)
 
 /*
  * Early initcalls run before initializing SMP.
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 43/74] lto, workaround: Disable LTO for sys_ni to work around alias bugs

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

LTO gcc has trouble with the weak alias definitions in sys_ni.
This leads to missing symbols.  Just disable LTO for this file.

Signed-off-by: Andi Kleen 
---
 kernel/Makefile |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/Makefile b/kernel/Makefile
index c0cc67a..4b37677 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -22,6 +22,8 @@ CFLAGS_REMOVE_cgroup-debug.o = -pg
 CFLAGS_REMOVE_irq_work.o = -pg
 endif
 
+CFLAGS_sys_ni.o = $(DISABLE_LTO)
+
 obj-y += sched/
 obj-y += power/
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/74] sections: Add __visible to rapidio sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 drivers/rapidio/rio.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rapidio/rio.h b/drivers/rapidio/rio.h
index b1af414..1fd0138 100644
--- a/drivers/rapidio/rio.h
+++ b/drivers/rapidio/rio.h
@@ -44,8 +44,8 @@ extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct 
rio_dev *from);
 extern struct device_attribute rio_dev_attrs[];
 extern spinlock_t rio_global_list_lock;
 
-extern struct rio_switch_ops __start_rio_switch_ops[];
-extern struct rio_switch_ops __end_rio_switch_ops[];
+extern __visible struct rio_switch_ops __start_rio_switch_ops[];
+extern __visible struct rio_switch_ops __end_rio_switch_ops[];
 
 /* Helpers internal to the RIO core code */
 #define DECLARE_RIO_SWITCH_SECTION(section, name, vid, did, init_hook) \
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 33/74] x86, lto, apm: Make APM data structure used from assembler visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/x86/kernel/apm_32.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index d65464e..61c9aa7 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -370,7 +370,7 @@ struct apm_user {
 /*
  * Local variables
  */
-static struct {
+__visible struct {
unsigned long   offset;
unsigned short  segment;
 } apm_bios_entry;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 41/74] x86, lto: Disable LTO for the x86 VDSO

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The VDSO does not play well with LTO, so just disable LTO for it.
Also pass a 32bit linker flag for the 32bit version.

Signed-off-by: Andi Kleen 
---
 arch/x86/vdso/Makefile |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index fd14be1..b2e15f2 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -2,6 +2,8 @@
 # Building vDSO images for x86.
 #
 
+KBUILD_CFLAGS += ${DISABLE_LTO}
+
 VDSO64-$(CONFIG_X86_64):= y
 VDSOX32-$(CONFIG_X86_X32_ABI)  := y
 VDSO32-$(CONFIG_X86_32):= y
@@ -35,7 +37,8 @@ export CPPFLAGS_vdso.lds += -P -C
 
 VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
-Wl,--no-undefined \
-   -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
+   -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \
+   $(DISABLE_LTO)
 
 $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
 
@@ -127,7 +130,7 @@ vdso32.so-$(VDSO32-y)   += sysenter
 vdso32-images  = $(vdso32.so-y:%=vdso32-%.so)
 
 CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
-VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1
+VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1
 
 # This makes sure the $(obj) subdirectory exists even though vdso32/
 # is not a kbuild sub-make subdirectory.
@@ -181,7 +184,8 @@ quiet_cmd_vdso = VDSO$@
   -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
 
-VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
+VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) 
\
+   ${LTO_CFLAGS}
 GCOV_PROFILE := n
 
 #
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 51/74] x86, lto, efi: Mark the efi variable used from assembler __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/x86/platform/efi/efi.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 2dc29f5..02bc41a 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -53,7 +53,7 @@
 int efi_enabled;
 EXPORT_SYMBOL(efi_enabled);
 
-struct efi __read_mostly efi = {
+struct efi __visible __read_mostly efi = {
.mps= EFI_INVALID_TABLE_ADDR,
.acpi   = EFI_INVALID_TABLE_ADDR,
.acpi20 = EFI_INVALID_TABLE_ADDR,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 23/74] lto, mutex: Mark __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Various kernel/mutex.c functions can be called from
inline assembler, so they should be all global and
__visible

Signed-off-by: Andi Kleen 
---
 kernel/mutex.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/mutex.c b/kernel/mutex.c
index a307cc9..fef1585 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -56,8 +56,7 @@ EXPORT_SYMBOL(__mutex_init);
  * We also put the fastpath first in the kernel image, to make sure the
  * branch is predicted by the CPU as default-untaken.
  */
-static __used noinline void __sched
-__mutex_lock_slowpath(atomic_t *lock_count);
+__visible void __sched __mutex_lock_slowpath(atomic_t *lock_count);
 
 /**
  * mutex_lock - acquire the mutex
@@ -94,7 +93,7 @@ void __sched mutex_lock(struct mutex *lock)
 EXPORT_SYMBOL(mutex_lock);
 #endif
 
-static __used noinline void __sched __mutex_unlock_slowpath(atomic_t 
*lock_count);
+__visible void __sched __mutex_unlock_slowpath(atomic_t *lock_count);
 
 /**
  * mutex_unlock - release the mutex
@@ -338,7 +337,7 @@ __mutex_unlock_common_slowpath(atomic_t *lock_count, int 
nested)
 /*
  * Release the lock, slowpath:
  */
-static __used noinline void
+__visible void
 __mutex_unlock_slowpath(atomic_t *lock_count)
 {
__mutex_unlock_common_slowpath(lock_count, 1);
@@ -395,7 +394,7 @@ int __sched mutex_lock_killable(struct mutex *lock)
 }
 EXPORT_SYMBOL(mutex_lock_killable);
 
-static __used noinline void __sched
+__visible void __sched
 __mutex_lock_slowpath(atomic_t *lock_count)
 {
struct mutex *lock = container_of(lock_count, struct mutex, count);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RFC: Link Time Optimization support for the kernel

2012-08-18 Thread Andi Kleen
This rather large patchkit enables gcc Link Time Optimization (LTO) 
support for the kernel. 

With LTO gcc will do whole program optimizations for
the whole kernel and each module. This increases compile time,
but can generate faster code.

LTO allows gcc to inline functions between different files and
do various other optimization across the whole binary.

It might also trigger bugs due to more aggressive optimization.
It allows gcc to drop unused code. It also allows it to check
types over the whole program.

The build slow down is currently between 2-4x (with larger binaries
taking longer). Typical configs with reasonably sized vmlinux
compile with less than 4GB memory, but very large setups (like 
allyes) need upto 9GB.

You probably wouldn't use it for development, but it may become
a useful option in the future for release builds.

We see speedups in various benchmarks, but also still a few minor
regressions. There's still some outstanding tuning, both in compile
time and allow gcc even better optimization. Also the kernel currently
triggers some slow behaviour in gcc, which will hopefully improve
in future gcc versions, allowing faster LTO builds.

The kit contains workarounds for various toolchain problems with gcc 4.7.
Part of those will be hopefully removed with some upcoming changes.

Currently a special tool chain setup is needed for LTO, with
gcc 4.7 and HJ Lu's Linux binutils. Please see Documentation/lto-build 
for more details on how to install the right versions with the right setup.
The LTO code disables itself if it doesn't find the right toolchain
(however it may not be able to detect all misconfigurations)

This is in the RFC stage at this point. I only tested it on 32bit
and 64bit x86. Other architectures will undoubtedly need more
changes. I would be interested in any testing and benchmarking and
review.

Some options are currently disabled with LTO. MODVERSIONS I plan
to fix. Some others like the FUNCTION_TRACER (who rely on 
different options for specific files) may need compiler changes.

This patchkit relies on the separately posted const-sections patchkit
With LTO gcc insists on correct section attributes.

Available from

git://github.com/andikleen/linux-misc lto-3.6   (or -3.5 and -3.7 in the future)

Note the tree is frequently rebased.

Thanks to HJ Lu, Joe Mario, Honza Hubicka, Richard Guenther,
Don Zickus, Changlong Xie who helped with this project
(and probably some more who I forgot, sorry)

-Andi

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 64/74] Kbuild, lto: Add a gcc-ld script to let run gcc as ld

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

For LTO we need to run the link step with gcc, not ld.
Since there are a lot of linker options passed to it, add a gcc-ld wrapper
that wraps them as -Wl,

Signed-off-by: Andi Kleen 
---
 scripts/gcc-ld |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 scripts/gcc-ld

diff --git a/scripts/gcc-ld b/scripts/gcc-ld
new file mode 100644
index 000..cadab9a
--- /dev/null
+++ b/scripts/gcc-ld
@@ -0,0 +1,29 @@
+#!/bin/sh
+# run gcc with ld options
+# used as a wrapper to execute link time optimizations
+# yes virginia, this is not pretty
+
+ARGS="-nostdlib"
+
+while [ "$1" != "" ] ; do
+   case "$1" in
+   -save-temps|-m32|-m64) N="$1" ;;
+   -r) N="$1" ;;
+   -[Wg]*) N="$1" ;;
+   -[olv]|-[Ofd]*|-nostdlib) N="$1" ;;
+   --end-group|--start-group)
+N="-Wl,$1" ;;
+   -[RTFGhIezcbyYu]*|\
+--script|--defsym|-init|-Map|--oformat|-rpath|\
+-rpath-link|--sort-section|--section-start|-Tbss|-Tdata|-Ttext|\
+--version-script|--dynamic-list|--version-exports-symbol|--wrap|-m)
+   A="$1" ; shift ; N="-Wl,$A,$1" ;;
+   -[m]*) N="$1" ;;
+   -*) N="-Wl,$1" ;;
+   *)  N="$1" ;;
+   esac
+   ARGS="$ARGS $N"
+   shift
+done
+
+exec $CC $ARGS
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 68/74] Kbuild, lto: Add LTO build Documentation

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Add build documentation for LTO.

Signed-off-by: Andi Kleen 
---
 Documentation/lto-build |  115 +++
 1 files changed, 115 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/lto-build

diff --git a/Documentation/lto-build b/Documentation/lto-build
new file mode 100644
index 000..5da427a
--- /dev/null
+++ b/Documentation/lto-build
@@ -0,0 +1,115 @@
+Link time optimization (LTO) for the Linux kernel
+
+This is an experimental feature which still has various problems.
+
+Link Time Optimization allows the compiler to optimize the complete program
+instead of just each file.  Link Time Optimization was a new feature in gcc 
4.6,
+but only really works with gcc 4.7. The kernel LTO build also requires
+the Linux binutils (the normal FSF releases do not work at the moment)
+
+The compiler can inline functions between files and do some other global
+optimizations.  It will also drop unused functions which can make the kernel
+image smaller in some circumstances.  The binary gets somewhat larger.
+In return the resulting kernels (usually) have better performance.
+
+Build time and memory consumption at build time will increase.
+The build time penalty depends on the size of the vmlinux. Reasonable 
+sized vmlinux build about twice as long, much larger monolithic kernels 
+like allyesconfig ~4x as long. Modular kernels are less affected.
+
+Normal "reasonable" builds work with less than 4GB of RAM, but very large
+configurations like allyesconfig can need upto 9GB. 
+
+Issues:
+- Various workarounds in kernel needed for toolchain problem.
+- A few kernel features are currently incompatible with LTO, in particular
+function tracing, because they require special compiler flags for
+specific files, which is not supported in LTO right now.
+- The build is faster with LTO_SLIM enabled, but this still triggers
+problems in some circumstances (currently disabled)
+- Jobserver control for -j does not work correctly for the final
+LTO phase. The makefiles hardcodes -j
+
+Configuration:
+- Enable CONFIG_LTO_MENU and then disable CONFIG_LTO_DISABLE.
+This is mainly to not have allyesconfig default to LTO.
+- FUNCTION_TRACER, STACK_TRACER, FUNCTION_GRAPH_TRACER have to disabled
+because they are currently incompatible with LTO.
+- MODVERSIONS have to be disabled because they are not fixed for LTO
+yet.
+
+Requirements:
+- Enough memory: 4GB for a standard build, ~8GB for allyesconfig
+If you are tight on memory and use tmpfs as /tmp define TMPDIR and 
+point it to a directory on disk.  The peak memory usage
+happens single threaded (when lto-wpa merges types), so dialing
+back -j options will not help much.
+
+A 32bit compiler is unlikely to work due to the memory requirements.
+You can however build a kernel targetted at 32bit on a 64bit host.
+
+- Get the Linux binutils from
+http://www.kernel.org/pub/linux/devel/binutils/
+Sorry standard binutils releases don't work
+The kernel build has to use this linker, so if it is installed 
+in a non standard location use LD=... on the make line.
+
+- gcc 4.7 built with plugin ld (--with-plugin-ld) also pointing to the 
+linker from the Linux binutils and LTO 
+
+Example build procedure for the tool chain and kernel. This does not 
+overwrite the standard compiler toolchain on the system. If you already
+have a suitable gcc 4.7+ compiler and linker the toolchain build can
+be skipped (note that a distribution gcc 4.7 is not necessarily
+correctly configured for LTO)
+
+Get the Linux binutils from http://www.kernel.org/pub/linux/devel/binutils/
+The standard binutils do not work at this point!
+
+Unpack binutils
+
+cd binutils-VERSION  (or plain binutils in some versions)
+./configure --prefix=/opt/binutils-VERSION --enable-plugins
+nice -n20 make -j$(getconf _NPROCESSORS_ONLN)
+sudo make install
+sudo ln -sf /opt/binutils-VERSION/bin/ld /usr/local/bin/ld-plugin
+
+Unpack gcc-4.7
+
+mkdir obj-gcc
+# please don't skip this cd. the build will not work correctly in the 
+# source dir, you have to use the separate object dir
+cd obj-gcc
+# make sure to install gmp-devel and mpfr-devel
+# and the 32bit glibc package if you have a multilib system
+# if mpc-devel is not there get it from
+# http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz
+# and install in gcc-4.7*/mpc
+../gcc-4.7*/configure --prefix=/opt/gcc-4.7 --enable-lto \
+--with-plugin-ld=/usr/local/bin/ld-plugin  \
+--disable-nls --enable-languages=c,c++ \
+--disable-libstdcxx-pch
+nice -n20 make -j$(getconf _NPROCESSORS_ONLN) 
+sudo make install-no-fixedincludes
+sudo ln -sf /opt/gcc-4.7/bin/gcc /usr/local/bin/gcc47
+sudo ln -sf /opt/gcc-4.7/bin/gcc-ar /usr/local/bin/gcc-ar47
+
+# get lto tree in linux-lto
+
+mkdir obj-lto
+cd obj-lto
+# copy a suitable kernel config file into .config
+make -C ../linux-lto O=$(pwd)  oldconfig
+./source/scripts/config --disable function_tracer --disable 
function_graph_tracer \
+--disable 

[PATCH 46/74] x86, lto: Disable fancy hweight optimizations for LTO

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The fancy x86 hweight uses different compiler options for the
hweight file. This does not work with LTO. Just disable the optimization
with LTO

Signed-off-by: Andi Kleen 
---
 arch/x86/Kconfig|5 +++--
 arch/x86/include/asm/arch_hweight.h |9 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 8ec3a1a..9382b09 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -224,8 +224,9 @@ config X86_32_LAZY_GS
 
 config ARCH_HWEIGHT_CFLAGS
string
-   default "-fcall-saved-ecx -fcall-saved-edx" if X86_32
-   default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx 
-fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 
-fcall-saved-r11" if X86_64
+   default "-fcall-saved-ecx -fcall-saved-edx" if X86_32 && !LTO
+   default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx 
-fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 
-fcall-saved-r11" if X86_64 && !LTO
+   default "" if LTO
 
 config ARCH_CPU_PROBE_RELEASE
def_bool y
diff --git a/arch/x86/include/asm/arch_hweight.h 
b/arch/x86/include/asm/arch_hweight.h
index 9686c3d..ca80549 100644
--- a/arch/x86/include/asm/arch_hweight.h
+++ b/arch/x86/include/asm/arch_hweight.h
@@ -25,9 +25,14 @@ static inline unsigned int __arch_hweight32(unsigned int w)
 {
unsigned int res = 0;
 
+#ifdef CONFIG_LTO
+   res  = __sw_hweight32(w);
+#else
+
asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, X86_FEATURE_POPCNT)
 : "="REG_OUT (res)
 : REG_IN (w));
+#endif
 
return res;
 }
@@ -46,6 +51,9 @@ static inline unsigned long __arch_hweight64(__u64 w)
 {
unsigned long res = 0;
 
+#ifdef CONFIG_LTO
+   res = __sw_hweight64(w);
+#else
 #ifdef CONFIG_X86_32
return  __arch_hweight32((u32)w) +
__arch_hweight32((u32)(w >> 32));
@@ -54,6 +62,7 @@ static inline unsigned long __arch_hweight64(__u64 w)
 : "="REG_OUT (res)
 : REG_IN (w));
 #endif /* CONFIG_X86_32 */
+#endif
 
return res;
 }
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 67/74] Kbuild, lto: Add Link Time Optimization support

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

With LTO gcc will do whole program optimizations for
the whole kernel and each module. This increases compile time,
but can generate faster code.

LTO allows gcc to inline functions between different files and
do various other optimization across the whole binary.

It might also trigger bugs due to more aggressive optimization.
It allows gcc to drop unused code. It also allows it to check
types over the whole program.

This adds the basic Kbuild plumbing for LTO:

- In Kbuild add a new scripts/Makefile.lto that checks
the tool chain (note the checks may not be fully bulletproof)
and when the tests pass sets the LTO options
Currently LTO is very finicky about the tool chain.
- Add a new LDFINAL variable that controls the final link
for vmlinux or module. In this case we call gcc-ld instead
of ld, to run the LTO step.
- For slim LTO builds (object files containing no backup
executable) force AR to gcc-ar
- Theoretically LTO should pass through compiler options from
the compiler to the link step, but this doesn't work for all options.
So the Makefile sets most of these options manually.
- Kconfigs:
Since LTO with allyesconfig needs more than 4G of memory (~8G)
and has the potential to makes people's system swap to death.
I used a nested config that ensures that a simple
allyesconfig disables LTO. It has to be explicitely
enabled.
- Some depencies on other Kconfigs:
MODVERSIONS, GCOV, FUNCTION_TRACER, single chain WCHAN are
incompatible with LTO currently. MODVERSIONS should be fixable,
but the others require setting special compiler options
for specific files, which LTO currently doesn't support.
I also disable strict copy user checks because they trigger
errors with LTO.

For more information see Documentation/lto-build

Thanks to HJ Lu, Joe Mario, Honza Hubicka, Richard Guenther,
Don Zickus, Changlong Xie who helped with this project
(and probably some more who I forgot, sorry)

Signed-off-by: Andi Kleen 
---
 Makefile |9 +-
 arch/x86/Kconfig |2 +-
 arch/x86/Kconfig.debug   |2 +-
 init/Kconfig |   58 ++
 kernel/gcov/Kconfig  |2 +-
 scripts/Makefile.lto |   69 ++
 scripts/Makefile.modpost |2 +-
 scripts/link-vmlinux.sh  |4 +-
 8 files changed, 141 insertions(+), 7 deletions(-)
 create mode 100644 scripts/Makefile.lto

diff --git a/Makefile b/Makefile
index 9cc77ac..b80c080 100644
--- a/Makefile
+++ b/Makefile
@@ -326,9 +326,14 @@ include $(srctree)/scripts/Kbuild.include
 
 AS = $(CROSS_COMPILE)as
 LD = $(CROSS_COMPILE)ld
+LDFINAL= $(LD)
 CC = $(CROSS_COMPILE)gcc
 CPP= $(CC) -E
+ifdef CONFIG_LTO_SLIM
+AR = $(CROSS_COMPILE)gcc-ar
+else
 AR = $(CROSS_COMPILE)ar
+endif
 NM = $(CROSS_COMPILE)nm
 STRIP  = $(CROSS_COMPILE)strip
 OBJCOPY= $(CROSS_COMPILE)objcopy
@@ -377,7 +382,7 @@ KERNELVERSION = $(VERSION)$(if 
$(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(S
 
 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
 export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
-export CPP AR NM STRIP OBJCOPY OBJDUMP
+export CPP AR NM STRIP OBJCOPY OBJDUMP LDFINAL
 export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE
 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
 
@@ -647,6 +652,8 @@ ifeq ($(shell $(CONFIG_SHELL) 
$(srctree)/scripts/gcc-goto.sh $(CC)), y)
KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
 endif
 
+include ${srctree}/scripts/Makefile.lto
+
 # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
 # But warn user when we do so
 warn-assign = \
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 9382b09..2e2974f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -540,7 +540,7 @@ config X86_32_IRIS
 
 config SCHED_OMIT_FRAME_POINTER
def_bool y
-   prompt "Single-depth WCHAN output"
+   prompt "Single-depth WCHAN output" if !LTO && !FRAME_POINTER
depends on X86
---help---
  Calculate simpler /proc//wchan values. If this option
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index b322f12..7961491 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
 
 config DEBUG_STRICT_USER_COPY_CHECKS
bool "Strict copy size checks"
-   depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
+   depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !LTO
---help---
  Enabling this option turns a certain set of sanity checks for user
  copy operations into compile time failures.
diff --git a/init/Kconfig b/init/Kconfig
index a8785db..0b972ab 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1135,6 +1135,63 @@ config CC_OPTIMIZE_FOR_SIZE
 
  If unsure, say Y.
 
+config LTO_MENU
+   bool "Enable gcc link time optimizations"
+

[PATCH 70/74] Kbuild, lto: Handle longer symbols in kallsyms.c

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Also warn for too long symbols

Signed-off-by: Andi Kleen 
---
 scripts/kallsyms.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 487ac6f..acde016 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -27,7 +27,7 @@
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
 #endif
 
-#define KSYM_NAME_LEN  128
+#define KSYM_NAME_LEN  256
 
 struct sym_entry {
unsigned long long addr;
@@ -111,6 +111,12 @@ static int read_symbol(FILE *in, struct sym_entry *s)
fprintf(stderr, "Read error or end of file.\n");
return -1;
}
+   if (strlen(str) > KSYM_NAME_LEN) {
+   fprintf(stderr, "Symbol %s too long for kallsyms.\n"
+"Please increae KSYM_NAME_LEN both in kernel 
and kallsyms.c",
+   str);
+   return -1;
+   }
 
sym = str;
/* skip prefix char */
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 62/74] Kbuild, lto: add ld-version and ld-ifversion macros

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

To check the linker version. Used by the LTO makefile.

Signed-off-by: Andi Kleen 
---
 scripts/Kbuild.include |9 +
 scripts/ld-version.sh  |8 
 2 files changed, 17 insertions(+), 0 deletions(-)
 create mode 100755 scripts/ld-version.sh

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 6a3ee98..bda5b20 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -155,6 +155,15 @@ ld-option = $(call try-run,\
 # Important: no spaces around options
 ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
 
+# ld-version
+# Usage: $(call ld-version)
+# Note this is mainly for HJ Lu's 3 number binutil versions
+ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
+
+# ld-ifversion
+# Usage:  $(call ld-ifversion, -ge, 22252, y)
+ld-ifversion = $(shell [ $(call ld-version) $(1) $(2) ] && echo $(3))
+
 ##
 
 ###
diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
new file mode 100755
index 000..7eb0b76
--- /dev/null
+++ b/scripts/ld-version.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/awk -f
+# extra linker version number from stdin and turn into single number
+   { 
+   gsub(".*)", ""); 
+   split($1,a, "."); 
+   print a[1]*1000 + a[2]*10 + a[3]*1 + a[4]*100 + a[5]; 
+   exit 
+   }
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 45/74] lto: Mark rwsem functions that can be called from assembler asmlinkage

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 lib/rwsem.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/rwsem.c b/lib/rwsem.c
index 8337e1b..4a33b58 100644
--- a/lib/rwsem.c
+++ b/lib/rwsem.c
@@ -222,6 +222,7 @@ rwsem_down_failed_common(struct rw_semaphore *sem,
 /*
  * wait for the read lock to be granted
  */
+__visible
 struct rw_semaphore __sched *rwsem_down_read_failed(struct rw_semaphore *sem)
 {
return rwsem_down_failed_common(sem, RWSEM_WAITING_FOR_READ,
@@ -231,6 +232,7 @@ struct rw_semaphore __sched *rwsem_down_read_failed(struct 
rw_semaphore *sem)
 /*
  * wait for the write lock to be granted
  */
+__visible
 struct rw_semaphore __sched *rwsem_down_write_failed(struct rw_semaphore *sem)
 {
return rwsem_down_failed_common(sem, RWSEM_WAITING_FOR_WRITE,
@@ -241,6 +243,7 @@ struct rw_semaphore __sched *rwsem_down_write_failed(struct 
rw_semaphore *sem)
  * handle waking up a waiter on the semaphore
  * - up_read/up_write has decremented the active part of count if we come here
  */
+__visible
 struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem)
 {
unsigned long flags;
@@ -261,6 +264,7 @@ struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem)
  * - caller incremented waiting part of count and discovered it still negative
  * - just wake up any readers at the front of the queue
  */
+__visible
 struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem)
 {
unsigned long flags;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 49/74] x86, lto, paravirt: Add __visible/asmlinkage to xen paravirt ops

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Cc: jer...@goop.org
Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/paravirt_types.h |3 ++-
 arch/x86/xen/xen-ops.h|   16 
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/x86/include/asm/paravirt_types.h 
b/arch/x86/include/asm/paravirt_types.h
index 142236e..4f262bc 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -386,7 +386,8 @@ extern struct pv_lock_ops pv_lock_ops;
 
 /* Simple instruction patching code. */
 #define DEF_NATIVE(ops, name, code)\
-   extern const char start_##ops##_##name[], end_##ops##_##name[]; \
+   extern const char start_##ops##_##name[] __visible, \
+ end_##ops##_##name[] __visible;   \
asm("start_" #ops "_" #name ": " code "; end_" #ops "_" #name ":")
 
 unsigned paravirt_patch_nop(void);
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 1e4329e..1c4c94e 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -105,9 +105,9 @@ static inline void __init xen_init_apic(void)
 /* Declare an asm function, along with symbols needed to make it
inlineable */
 #define DECL_ASM(ret, name, ...)   \
-   ret name(__VA_ARGS__);  \
-   extern char name##_end[];   \
-   extern char name##_reloc[]  \
+   asmlinkage ret name(__VA_ARGS__);   \
+   extern char name##_end[] __visible; \
+   extern char name##_reloc[] __visible
 
 DECL_ASM(void, xen_irq_enable_direct, void);
 DECL_ASM(void, xen_irq_disable_direct, void);
@@ -115,11 +115,11 @@ DECL_ASM(unsigned long, xen_save_fl_direct, void);
 DECL_ASM(void, xen_restore_fl_direct, unsigned long);
 
 /* These are not functions, and cannot be called normally */
-void xen_iret(void);
-void xen_sysexit(void);
-void xen_sysret32(void);
-void xen_sysret64(void);
-void xen_adjust_exception_frame(void);
+asmlinkage void xen_iret(void);
+asmlinkage void xen_sysexit(void);
+asmlinkage void xen_sysret32(void);
+asmlinkage void xen_sysret64(void);
+asmlinkage void xen_adjust_exception_frame(void);
 
 extern int xen_panic_handler_init(void);
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 71/74] lto, kprobes: Use KSYM_NAME_LEN to size identifier buffers

2012-08-18 Thread Andi Kleen
From: Joe Mario 

Use KSYM_NAME_LEN to size identifier buffers, so that it can
be easier increased.

Cc: ana...@in.ibm.com
Signed-off-by: Joe Mario 
Signed-off-by: Andi Kleen 
---
 kernel/kprobes.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c62b854..b9bd2a8 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1955,7 +1955,7 @@ static int __init init_kprobes(void)
 {
int i, err = 0;
unsigned long offset = 0, size = 0;
-   char *modname, namebuf[128];
+   char *modname, namebuf[KSYM_NAME_LEN];
const char *symbol_name;
void *addr;
struct kprobe_blackpoint *kb;
@@ -2081,7 +2081,7 @@ static int __kprobes show_kprobe_addr(struct seq_file 
*pi, void *v)
const char *sym = NULL;
unsigned int i = *(loff_t *) v;
unsigned long offset = 0;
-   char *modname, namebuf[128];
+   char *modname, namebuf[KSYM_NAME_LEN];
 
head = _table[i];
preempt_disable();
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 22/74] lto: Change kernel_execve to asmlinkage for all architectures

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

The x86 kernel_execve has to be asmlinkage because it's called from
assembler code. To make it consistent I have to also change
the prototype in linux/syscalls.h

This in turn requires adding asmlinkage to all architectures.

Do this here in a tree sweep.

Signed-off-by: Andi Kleen 
---
 arch/arm/kernel/sys_arm.c   |1 +
 arch/avr32/kernel/sys_avr32.c   |1 +
 arch/m32r/kernel/sys_m32r.c |1 +
 arch/microblaze/kernel/sys_microblaze.c |1 +
 arch/mips/kernel/syscall.c  |1 +
 arch/parisc/kernel/process.c|1 +
 arch/sh/kernel/sys_sh32.c   |1 +
 arch/sh/kernel/sys_sh64.c   |1 +
 arch/sparc/kernel/sys_sparc_32.c|1 +
 arch/sparc/kernel/sys_sparc_64.c|1 +
 arch/um/kernel/syscall.c|1 +
 arch/unicore32/kernel/sys.c |1 +
 arch/x86/kernel/sys_i386_32.c   |2 +-
 include/linux/syscalls.h|1 +
 14 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 76cbb05..50b1bf1 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -79,6 +79,7 @@ out:
return error;
 }
 
+asmlinkage
 int kernel_execve(const char *filename,
  const char *const argv[],
  const char *const envp[])
diff --git a/arch/avr32/kernel/sys_avr32.c b/arch/avr32/kernel/sys_avr32.c
index 62635a0..94d7121 100644
--- a/arch/avr32/kernel/sys_avr32.c
+++ b/arch/avr32/kernel/sys_avr32.c
@@ -7,6 +7,7 @@
  */
 #include 
 
+asmlinkage
 int kernel_execve(const char *file,
  const char *const *argv,
  const char *const *envp)
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
index d841fb6..b7b2581 100644
--- a/arch/m32r/kernel/sys_m32r.c
+++ b/arch/m32r/kernel/sys_m32r.c
@@ -93,6 +93,7 @@ asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
  * Do a system call from kernel instead of calling sys_execve so we
  * end up with proper pt_regs.
  */
+asmlinkage
 int kernel_execve(const char *filename,
  const char *const argv[],
  const char *const envp[])
diff --git a/arch/microblaze/kernel/sys_microblaze.c 
b/arch/microblaze/kernel/sys_microblaze.c
index e5b154f..396b157 100644
--- a/arch/microblaze/kernel/sys_microblaze.c
+++ b/arch/microblaze/kernel/sys_microblaze.c
@@ -80,6 +80,7 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long 
len,
  * Do a system call from kernel instead of calling sys_execve so we
  * end up with proper pt_regs.
  */
+asmlinkage
 int kernel_execve(const char *filename,
  const char *const argv[],
  const char *const envp[])
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index b08220c..6282a7a 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -318,6 +318,7 @@ asmlinkage void bad_stack(void)
  * Do a system call from kernel instead of calling sys_execve so we
  * end up with proper pt_regs.
  */
+asmlinkage
 int kernel_execve(const char *filename,
  const char *const argv[],
  const char *const envp[])
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index d4b94b3..82f425e 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -358,6 +358,7 @@ out:
 extern int __execve(const char *filename,
const char *const argv[],
const char *const envp[], struct task_struct *task);
+asmlinkage
 int kernel_execve(const char *filename,
  const char *const argv[],
  const char *const envp[])
diff --git a/arch/sh/kernel/sys_sh32.c b/arch/sh/kernel/sys_sh32.c
index f56b6fe5..db3f53d 100644
--- a/arch/sh/kernel/sys_sh32.c
+++ b/arch/sh/kernel/sys_sh32.c
@@ -71,6 +71,7 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, 
u32 offset1,
  * Do a system call from kernel instead of calling sys_execve so we
  * end up with proper pt_regs.
  */
+asmlinkage
 int kernel_execve(const char *filename,
  const char *const argv[],
  const char *const envp[])
diff --git a/arch/sh/kernel/sys_sh64.c b/arch/sh/kernel/sys_sh64.c
index c5a38c4..cad6faa 100644
--- a/arch/sh/kernel/sys_sh64.c
+++ b/arch/sh/kernel/sys_sh64.c
@@ -33,6 +33,7 @@
  * Do a system call from kernel instead of calling sys_execve so we
  * end up with proper pt_regs.
  */
+asmlinkage
 int kernel_execve(const char *filename,
  const char *const argv[],
  const char *const envp[])
diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
index 0c9b31b..37e75dd 100644
--- a/arch/sparc/kernel/sys_sparc_32.c
+++ b/arch/sparc/kernel/sys_sparc_32.c
@@ -263,6 +263,7 @@ out:
  * Do a system call from kernel instead of calling sys_execve so we
  * end up with 

[PATCH 31/74] x86, lto: Make various variables used by assembler code __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/x86/kernel/cpu/common.c |4 ++--
 arch/x86/kernel/process_64.c |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 46d8786..8f12e8c 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1075,7 +1075,7 @@ EXPORT_PER_CPU_SYMBOL(kernel_stack);
 DEFINE_PER_CPU(char *, irq_stack_ptr) =
init_per_cpu_var(irq_stack_union.irq_stack) + IRQ_STACK_SIZE - 64;
 
-DEFINE_PER_CPU(unsigned int, irq_count) = -1;
+DEFINE_PER_CPU(unsigned int, irq_count) __visible = -1;
 
 DEFINE_PER_CPU(struct task_struct *, fpu_owner_task);
 
@@ -1114,7 +1114,7 @@ void syscall_init(void)
   X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|X86_EFLAGS_IOPL);
 }
 
-unsigned long kernel_eflags;
+unsigned long kernel_eflags __visible;
 
 /*
  * Copies of the original ist values from the tss are only accessed during
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index a5720ed..34435e2 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -52,7 +52,7 @@
 
 asmlinkage extern void ret_from_fork(void);
 
-DEFINE_PER_CPU(unsigned long, old_rsp);
+asmlinkage DEFINE_PER_CPU(unsigned long, old_rsp);
 
 /* Prints also some state that isn't saved in the pt_regs */
 void __show_regs(struct pt_regs *regs, int all)
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 40/74] lto, powerpc: Disable LTO for the powerpc VDSO

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

VDSO does not play well with LTO, so just disable it.

(note that powerpc will likely need more changes for LTO, this was
just from grep)

Cc: b...@kernel.crashing.org
Signed-off-by: Andi Kleen 
---
 arch/powerpc/kernel/vdso32/Makefile |2 +-
 arch/powerpc/kernel/vdso64/Makefile |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/vdso32/Makefile 
b/arch/powerpc/kernel/vdso32/Makefile
index 53e6c9b..8cc88bf 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -16,7 +16,7 @@ obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
 
 GCOV_PROFILE := n
 
-ccflags-y := -shared -fno-common -fno-builtin
+ccflags-y := -shared -fno-common -fno-builtin $(DISABLE_LTO)
 ccflags-y += -nostdlib -Wl,-soname=linux-vdso32.so.1 \
$(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
 asflags-y := -D__VDSO32__ -s
diff --git a/arch/powerpc/kernel/vdso64/Makefile 
b/arch/powerpc/kernel/vdso64/Makefile
index effca94..5bca644 100644
--- a/arch/powerpc/kernel/vdso64/Makefile
+++ b/arch/powerpc/kernel/vdso64/Makefile
@@ -9,7 +9,7 @@ obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
 
 GCOV_PROFILE := n
 
-ccflags-y := -shared -fno-common -fno-builtin
+ccflags-y := -shared -fno-common -fno-builtin $(DISABLE_LTO)
 ccflags-y += -nostdlib -Wl,-soname=linux-vdso64.so.1 \
$(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
 asflags-y := -D__VDSO64__ -s
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 66/74] Kbuild, lto: Handle basic LTO in modpost

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

- Don't warn for __gnu_lto_* COMMON symbols
- Don't complain about .gnu.lto* sections

Signed-off-by: Andi Kleen 
---
 scripts/mod/modpost.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index ccd34ff..11fc5a6 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -600,7 +600,8 @@ static void handle_modversions(struct module *mod, struct 
elf_info *info,
 
switch (sym->st_shndx) {
case SHN_COMMON:
-   warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
+   if (strncmp(symname, "__gnu_lto_", sizeof("__gnu_lto_")-1))
+   warn("\"%s\" [%s] is COMMON symbol\n", symname, 
mod->name);
break;
case SHN_ABS:
/* CRC'd symbol */
@@ -827,6 +828,7 @@ static const char *section_white_list[] =
".note*",
".got*",
".toc*",
+   ".gnu.lto*",
NULL
 };
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 32/74] lto, PNP: Fix the inline assembler to use asmlinkage symbols

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 drivers/pnp/pnpbios/bioscalls.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index 769d265..53a69a3 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -21,7 +21,7 @@
 
 #include "pnpbios.h"
 
-static struct {
+__visible struct {
u16 offset;
u16 segment;
 } pnp_bios_callpoint;
@@ -41,6 +41,7 @@ asmlinkage void pnp_bios_callfunc(void);
 
 __asm__(".text \n"
__ALIGN_STR "\n"
+   ".globl pnp_bios_callfunc\n"
"pnp_bios_callfunc:\n"
"   pushl %edx  \n"
"   pushl %ecx  \n"
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/74] sections: Add __visible to powerpc sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/powerpc/include/asm/cputable.h |2 +-
 arch/powerpc/include/asm/firmware.h |2 +-
 arch/powerpc/include/asm/mmu.h  |2 +-
 arch/powerpc/include/asm/synch.h|2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/cputable.h 
b/arch/powerpc/include/asm/cputable.h
index 50d82c8..048f876 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -125,7 +125,7 @@ struct cpu_spec {
 
 extern struct cpu_spec *cur_cpu_spec;
 
-extern unsigned int __start___ftr_fixup, __stop___ftr_fixup;
+extern __visible unsigned int __start___ftr_fixup, __stop___ftr_fixup;
 
 extern struct cpu_spec *identify_cpu(unsigned long offset, unsigned int pvr);
 extern void do_feature_fixups(unsigned long value, void *fixup_start,
diff --git a/arch/powerpc/include/asm/firmware.h 
b/arch/powerpc/include/asm/firmware.h
index ad0b751..fbf4834 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -128,7 +128,7 @@ extern void machine_check_fwnmi(void);
 /* This is true if we are using the firmware NMI handler (typically LPAR) */
 extern int fwnmi_active;
 
-extern unsigned int __start___fw_ftr_fixup, __stop___fw_ftr_fixup;
+extern __visible unsigned int __start___fw_ftr_fixup, __stop___fw_ftr_fixup;
 
 #endif /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index e8a26db..cb0a276 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -130,7 +130,7 @@ static inline void mmu_clear_feature(unsigned long feature)
cur_cpu_spec->mmu_features &= ~feature;
 }
 
-extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
+extern __visible unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
 
 /* MMU initialization */
 extern void early_init_mmu(void);
diff --git a/arch/powerpc/include/asm/synch.h b/arch/powerpc/include/asm/synch.h
index e682a71..b13b5f7 100644
--- a/arch/powerpc/include/asm/synch.h
+++ b/arch/powerpc/include/asm/synch.h
@@ -10,7 +10,7 @@
 #endif
 
 #ifndef __ASSEMBLY__
-extern unsigned int __start___lwsync_fixup, __stop___lwsync_fixup;
+extern __visible unsigned int __start___lwsync_fixup, __stop___lwsync_fixup;
 extern void do_lwsync_fixups(unsigned long value, void *fixup_start,
 void *fixup_end);
 extern void do_final_fixups(void);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/74] sections: Add __visible to tile sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/tile/include/asm/sections.h |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/tile/include/asm/sections.h b/arch/tile/include/asm/sections.h
index d062d46..edee549 100644
--- a/arch/tile/include/asm/sections.h
+++ b/arch/tile/include/asm/sections.h
@@ -27,11 +27,11 @@ extern char __w1data_begin[], __w1data_end[];
 
 
 /* Not exactly sections, but PC comparison points in the code. */
-extern char __rt_sigreturn[], __rt_sigreturn_end[];
+extern __visible char __rt_sigreturn[], __rt_sigreturn_end[];
 #ifndef __tilegx__
-extern char sys_cmpxchg[], __sys_cmpxchg_end[];
-extern char __sys_cmpxchg_grab_lock[];
-extern char __start_atomic_asm_code[], __end_atomic_asm_code[];
+extern __visible char sys_cmpxchg[], __sys_cmpxchg_end[];
+extern __visible char __sys_cmpxchg_grab_lock[];
+extern __visible char __start_atomic_asm_code[], __end_atomic_asm_code[];
 #endif
 
 /* Handle the discontiguity between _sdata and _stext. */
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 38/74] lto, watchdog/hpwdt.c: Make assembler label global

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

We cannot assume that the inline assembler code always ends up
in the same file as the original C file. So make any assembler labels
that are called with "extern" by C global

Cc: w...@iguana.be
Signed-off-by: Andi Kleen 
---
 drivers/watchdog/hpwdt.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 1eff743..68bda60 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -161,7 +161,8 @@ extern asmlinkage void asminline_call(struct cmn_registers 
*pi86Regs,
 #define HPWDT_ARCH 32
 
 asm(".text  \n\t"
-".align 4   \n"
+".align 4   \n\t"
+".globl asminline_call \n"
 "asminline_call:\n\t"
 "pushl   %ebp   \n\t"
 "movl%esp, %ebp \n\t"
@@ -351,7 +352,8 @@ static int __devinit detect_cru_service(void)
 #define HPWDT_ARCH 64
 
 asm(".text  \n\t"
-".align 4   \n"
+".align 4   \n\t"
+".globl asminline_call \n"
 "asminline_call:\n\t"
 "pushq  %rbp\n\t"
 "movq   %rsp, %rbp  \n\t"
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/74] sections: Add __visible to drivers/{base,pci} sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 drivers/base/firmware_class.c |4 ++--
 drivers/base/power/trace.c|2 +-
 drivers/pci/quirks.c  |   28 ++--
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 803cfc1..618ca735 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -30,8 +30,8 @@ MODULE_LICENSE("GPL");
 
 #ifdef CONFIG_FW_LOADER
 
-extern struct builtin_fw __start_builtin_fw[];
-extern struct builtin_fw __end_builtin_fw[];
+extern __visible struct builtin_fw __start_builtin_fw[];
+extern __visible struct builtin_fw __end_builtin_fw[];
 
 static bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
 {
diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
index d94a1f5..3048afa 100644
--- a/drivers/base/power/trace.c
+++ b/drivers/base/power/trace.c
@@ -166,7 +166,7 @@ void generate_resume_trace(const void *tracedata, unsigned 
int user)
 }
 EXPORT_SYMBOL(generate_resume_trace);
 
-extern char __tracedata_start, __tracedata_end;
+extern __visible char __tracedata_start, __tracedata_end;
 static int show_file_hash(unsigned int value)
 {
int match;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 5155317..d18ea93 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2941,20 +2941,20 @@ static void pci_do_fixups(struct pci_dev *dev, struct 
pci_fixup *f,
}
 }
 
-extern struct pci_fixup __start_pci_fixups_early[];
-extern struct pci_fixup __end_pci_fixups_early[];
-extern struct pci_fixup __start_pci_fixups_header[];
-extern struct pci_fixup __end_pci_fixups_header[];
-extern struct pci_fixup __start_pci_fixups_final[];
-extern struct pci_fixup __end_pci_fixups_final[];
-extern struct pci_fixup __start_pci_fixups_enable[];
-extern struct pci_fixup __end_pci_fixups_enable[];
-extern struct pci_fixup __start_pci_fixups_resume[];
-extern struct pci_fixup __end_pci_fixups_resume[];
-extern struct pci_fixup __start_pci_fixups_resume_early[];
-extern struct pci_fixup __end_pci_fixups_resume_early[];
-extern struct pci_fixup __start_pci_fixups_suspend[];
-extern struct pci_fixup __end_pci_fixups_suspend[];
+extern __visible struct pci_fixup __start_pci_fixups_early[];
+extern __visible struct pci_fixup __end_pci_fixups_early[];
+extern __visible struct pci_fixup __start_pci_fixups_header[];
+extern __visible struct pci_fixup __end_pci_fixups_header[];
+extern __visible struct pci_fixup __start_pci_fixups_final[];
+extern __visible struct pci_fixup __end_pci_fixups_final[];
+extern __visible struct pci_fixup __start_pci_fixups_enable[];
+extern __visible struct pci_fixup __end_pci_fixups_enable[];
+extern __visible struct pci_fixup __start_pci_fixups_resume[];
+extern __visible struct pci_fixup __end_pci_fixups_resume[];
+extern __visible struct pci_fixup __start_pci_fixups_resume_early[];
+extern __visible struct pci_fixup __end_pci_fixups_resume_early[];
+extern __visible struct pci_fixup __start_pci_fixups_suspend[];
+extern __visible struct pci_fixup __end_pci_fixups_suspend[];
 
 static bool pci_apply_fixup_final_quirks;
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 35/74] lto, crypto, aes: mark AES tables __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Various tables in aes_generic are accessed by assembler code.
Mark them __visible for LTO

Cc: herb...@gondor.apana.org.au
Signed-off-by: Andi Kleen 
---
 crypto/aes_generic.c |8 
 include/crypto/aes.h |8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/crypto/aes_generic.c b/crypto/aes_generic.c
index a68c73d..1cf1f89 100644
--- a/crypto/aes_generic.c
+++ b/crypto/aes_generic.c
@@ -62,7 +62,7 @@ static inline u8 byte(const u32 x, const unsigned n)
 
 static const u32 rco_tab[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 27, 54 };
 
-const u32 crypto_ft_tab[4][256] = {
+__visible const u32 crypto_ft_tab[4][256] = {
{
0xa56363c6, 0x847c7cf8, 0x99ee, 0x8d7b7bf6,
0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591,
@@ -326,7 +326,7 @@ const u32 crypto_ft_tab[4][256] = {
}
 };
 
-const u32 crypto_fl_tab[4][256] = {
+__visible const u32 crypto_fl_tab[4][256] = {
{
0x0063, 0x007c, 0x0077, 0x007b,
0x00f2, 0x006b, 0x006f, 0x00c5,
@@ -590,7 +590,7 @@ const u32 crypto_fl_tab[4][256] = {
}
 };
 
-const u32 crypto_it_tab[4][256] = {
+__visible const u32 crypto_it_tab[4][256] = {
{
0x50a7f451, 0x5365417e, 0xc3a4171a, 0x965e273a,
0xcb6bab3b, 0xf1459d1f, 0xab58faac, 0x9303e34b,
@@ -854,7 +854,7 @@ const u32 crypto_it_tab[4][256] = {
}
 };
 
-const u32 crypto_il_tab[4][256] = {
+__visible const u32 crypto_il_tab[4][256] = {
{
0x0052, 0x0009, 0x006a, 0x00d5,
0x0030, 0x0036, 0x00a5, 0x0038,
diff --git a/include/crypto/aes.h b/include/crypto/aes.h
index 7524ba3..f30d38d 100644
--- a/include/crypto/aes.h
+++ b/include/crypto/aes.h
@@ -27,10 +27,10 @@ struct crypto_aes_ctx {
u32 key_length;
 };
 
-extern const u32 crypto_ft_tab[4][256];
-extern const u32 crypto_fl_tab[4][256];
-extern const u32 crypto_it_tab[4][256];
-extern const u32 crypto_il_tab[4][256];
+extern __visible const u32 crypto_ft_tab[4][256];
+extern __visible const u32 crypto_fl_tab[4][256];
+extern __visible const u32 crypto_it_tab[4][256];
+extern __visible const u32 crypto_il_tab[4][256];
 
 int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
unsigned int key_len);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/74] sections: Make external kallsyms tables __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 kernel/kallsyms.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 2169fee..1b40cb7 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -36,20 +36,20 @@
  * These will be re-linked against their real values
  * during the second link stage.
  */
-extern const unsigned long kallsyms_addresses[] __attribute__((weak));
-extern const u8 kallsyms_names[] __attribute__((weak));
+extern __visible const unsigned long kallsyms_addresses[] 
__attribute__((weak));
+extern __visible const u8 kallsyms_names[] __attribute__((weak));
 
 /*
  * Tell the compiler that the count isn't in the small data section if the arch
  * has one (eg: FRV).
  */
-extern const unsigned long kallsyms_num_syms
+extern __visible const unsigned long kallsyms_num_syms
 __attribute__((weak, section(".rodata")));
 
-extern const u8 kallsyms_token_table[] __attribute__((weak));
-extern const u16 kallsyms_token_index[] __attribute__((weak));
+extern __visible const u8 kallsyms_token_table[] __attribute__((weak));
+extern __visible const u16 kallsyms_token_index[] __attribute__((weak));
 
-extern const unsigned long kallsyms_markers[] __attribute__((weak));
+extern __visible const unsigned long kallsyms_markers[] __attribute__((weak));
 
 static inline int is_kernel_inittext(unsigned long addr)
 {
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/74] sections: Make all standard section identifiers __visible

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 include/asm-generic/sections.h |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index c1a1216..eab95aa 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -3,20 +3,20 @@
 
 /* References to section boundaries */
 
-extern char _text[], _stext[], _etext[];
-extern char _data[], _sdata[], _edata[];
-extern char __bss_start[], __bss_stop[];
-extern char __init_begin[], __init_end[];
-extern char _sinittext[], _einittext[];
-extern char _end[];
-extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
-extern char __kprobes_text_start[], __kprobes_text_end[];
-extern char __entry_text_start[], __entry_text_end[];
-extern char __initdata_begin[], __initdata_end[];
-extern char __start_rodata[], __end_rodata[];
+extern __visible char _text[], _stext[], _etext[];
+extern __visible char _data[], _sdata[], _edata[];
+extern __visible char __bss_start[], __bss_stop[];
+extern __visible char __init_begin[], __init_end[];
+extern __visible char _sinittext[], _einittext[];
+extern __visible char _end[];
+extern __visible char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
+extern __visible char __kprobes_text_start[], __kprobes_text_end[];
+extern __visible char __entry_text_start[], __entry_text_end[];
+extern __visible char __initdata_begin[], __initdata_end[];
+extern __visible char __start_rodata[], __end_rodata[];
 
 /* Start and end of .ctors section - used for constructor calls. */
-extern char __ctors_start[], __ctors_end[];
+extern __visible char __ctors_start[], __ctors_end[];
 
 /* function descriptor handling (if any).  Override
  * in asm/sections.h */
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 25/74] x86, lto: Fix sys_call_table type in asm/syscall.h v2

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Make the sys_call_table type defined in asm/syscall.h match
the definition in syscall_64.c

v2: include asm/syscall.h in syscall_64.c too. I left uml alone
because it doesn't have an syscall.h on its own and including
the native one leads to other errors.
Cc: x...@kernel.org
Signed-off-by: Andi Kleen 
---
 arch/x86/include/asm/syscall.h |3 ++-
 arch/x86/kernel/syscall_64.c   |3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h
index 1ace47b..c36962d 100644
--- a/arch/x86/include/asm/syscall.h
+++ b/arch/x86/include/asm/syscall.h
@@ -20,7 +20,8 @@
 #include/* for TS_COMPAT */
 #include 
 
-extern const unsigned long sys_call_table[];
+typedef void (*sys_call_ptr_t)(void);
+extern const sys_call_ptr_t sys_call_table[];
 
 /*
  * Only the low 32 bits of orig_ax are meaningful, so we return int.
diff --git a/arch/x86/kernel/syscall_64.c b/arch/x86/kernel/syscall_64.c
index 3967318..4ac730b 100644
--- a/arch/x86/kernel/syscall_64.c
+++ b/arch/x86/kernel/syscall_64.c
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define __SYSCALL_COMMON(nr, sym, compat) __SYSCALL_64(nr, sym, compat)
 
@@ -19,8 +20,6 @@
 
 #define __SYSCALL_64(nr, sym, compat) [nr] = sym,
 
-typedef void (*sys_call_ptr_t)(void);
-
 extern void sys_ni_syscall(void);
 
 asmlinkage const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 72/74] lto: Mark spinlocks noinline when inline spinlocks are disabled

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Otherwise LTO will inline them anyways

Signed-off-by: Andi Kleen 
---
 kernel/spinlock.c |   56 ++--
 1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index 75439be..e68917a 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -116,7 +116,7 @@ BUILD_LOCK_OPS(write, rwlock);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_TRYLOCK
-int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock)
+noinline int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock)
 {
return __raw_spin_trylock(lock);
 }
@@ -124,7 +124,7 @@ EXPORT_SYMBOL(_raw_spin_trylock);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_TRYLOCK_BH
-int __lockfunc _raw_spin_trylock_bh(raw_spinlock_t *lock)
+noinline int __lockfunc _raw_spin_trylock_bh(raw_spinlock_t *lock)
 {
return __raw_spin_trylock_bh(lock);
 }
@@ -132,7 +132,7 @@ EXPORT_SYMBOL(_raw_spin_trylock_bh);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_LOCK
-void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)
+noinline void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)
 {
__raw_spin_lock(lock);
 }
@@ -140,7 +140,7 @@ EXPORT_SYMBOL(_raw_spin_lock);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
-unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
+noinline unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
 {
return __raw_spin_lock_irqsave(lock);
 }
@@ -148,7 +148,7 @@ EXPORT_SYMBOL(_raw_spin_lock_irqsave);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_LOCK_IRQ
-void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
+noinline void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
 {
__raw_spin_lock_irq(lock);
 }
@@ -156,7 +156,7 @@ EXPORT_SYMBOL(_raw_spin_lock_irq);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_LOCK_BH
-void __lockfunc _raw_spin_lock_bh(raw_spinlock_t *lock)
+noinline void __lockfunc _raw_spin_lock_bh(raw_spinlock_t *lock)
 {
__raw_spin_lock_bh(lock);
 }
@@ -164,7 +164,7 @@ EXPORT_SYMBOL(_raw_spin_lock_bh);
 #endif
 
 #ifdef CONFIG_UNINLINE_SPIN_UNLOCK
-void __lockfunc _raw_spin_unlock(raw_spinlock_t *lock)
+noinline void __lockfunc _raw_spin_unlock(raw_spinlock_t *lock)
 {
__raw_spin_unlock(lock);
 }
@@ -172,7 +172,7 @@ EXPORT_SYMBOL(_raw_spin_unlock);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
-void __lockfunc _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned 
long flags)
+noinline void __lockfunc _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, 
unsigned long flags)
 {
__raw_spin_unlock_irqrestore(lock, flags);
 }
@@ -180,7 +180,7 @@ EXPORT_SYMBOL(_raw_spin_unlock_irqrestore);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQ
-void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)
+noinline void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)
 {
__raw_spin_unlock_irq(lock);
 }
@@ -188,7 +188,7 @@ EXPORT_SYMBOL(_raw_spin_unlock_irq);
 #endif
 
 #ifndef CONFIG_INLINE_SPIN_UNLOCK_BH
-void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock)
+noinline void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock)
 {
__raw_spin_unlock_bh(lock);
 }
@@ -196,7 +196,7 @@ EXPORT_SYMBOL(_raw_spin_unlock_bh);
 #endif
 
 #ifndef CONFIG_INLINE_READ_TRYLOCK
-int __lockfunc _raw_read_trylock(rwlock_t *lock)
+noinline int __lockfunc _raw_read_trylock(rwlock_t *lock)
 {
return __raw_read_trylock(lock);
 }
@@ -204,7 +204,7 @@ EXPORT_SYMBOL(_raw_read_trylock);
 #endif
 
 #ifndef CONFIG_INLINE_READ_LOCK
-void __lockfunc _raw_read_lock(rwlock_t *lock)
+noinline void __lockfunc _raw_read_lock(rwlock_t *lock)
 {
__raw_read_lock(lock);
 }
@@ -212,7 +212,7 @@ EXPORT_SYMBOL(_raw_read_lock);
 #endif
 
 #ifndef CONFIG_INLINE_READ_LOCK_IRQSAVE
-unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock)
+noinline unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock)
 {
return __raw_read_lock_irqsave(lock);
 }
@@ -220,7 +220,7 @@ EXPORT_SYMBOL(_raw_read_lock_irqsave);
 #endif
 
 #ifndef CONFIG_INLINE_READ_LOCK_IRQ
-void __lockfunc _raw_read_lock_irq(rwlock_t *lock)
+noinline void __lockfunc _raw_read_lock_irq(rwlock_t *lock)
 {
__raw_read_lock_irq(lock);
 }
@@ -228,7 +228,7 @@ EXPORT_SYMBOL(_raw_read_lock_irq);
 #endif
 
 #ifndef CONFIG_INLINE_READ_LOCK_BH
-void __lockfunc _raw_read_lock_bh(rwlock_t *lock)
+noinline void __lockfunc _raw_read_lock_bh(rwlock_t *lock)
 {
__raw_read_lock_bh(lock);
 }
@@ -236,7 +236,7 @@ EXPORT_SYMBOL(_raw_read_lock_bh);
 #endif
 
 #ifndef CONFIG_INLINE_READ_UNLOCK
-void __lockfunc _raw_read_unlock(rwlock_t *lock)
+noinline void __lockfunc _raw_read_unlock(rwlock_t *lock)
 {
__raw_read_unlock(lock);
 }
@@ -244,7 +244,7 @@ EXPORT_SYMBOL(_raw_read_unlock);
 #endif
 
 #ifndef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE
-void __lockfunc _raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long 
flags)
+noinline void __lockfunc _raw_read_unlock_irqrestore(rwlock_t *lock, unsigned 
long flags)
 {

[PATCH 09/74] sections: Add __visible to x86 sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/x86/kernel/alternative.c |4 ++--
 arch/x86/kernel/vsyscall_64.c |4 ++--
 arch/x86/power/hibernate_32.c |2 +-
 arch/x86/um/vdso/vma.c|2 +-
 arch/x86/vdso/vma.c   |   10 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index afb7ff7..27ae345 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -252,8 +252,8 @@ static void __init_or_module add_nops(void *insns, unsigned 
int len)
}
 }
 
-extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
-extern s32 __smp_locks[], __smp_locks_end[];
+extern __visible struct alt_instr __alt_instructions[], 
__alt_instructions_end[];
+extern __visible s32 __smp_locks[], __smp_locks_end[];
 void *text_poke_early(void *addr, const void *opcode, size_t len);
 
 /* Replace instructions with better alternatives for this CPU type.
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 8d141b3..70f25f2 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -355,9 +355,9 @@ cpu_vsyscall_notifier(struct notifier_block *n, unsigned 
long action, void *arg)
 
 void __init map_vsyscall(void)
 {
-   extern char __vsyscall_page;
+   extern __visible char __vsyscall_page;
unsigned long physaddr_vsyscall = __pa_symbol(&__vsyscall_page);
-   extern char __vvar_page;
+   extern __visible char __vvar_page;
unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
 
__set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
diff --git a/arch/x86/power/hibernate_32.c b/arch/x86/power/hibernate_32.c
index 74202c1..7b8d7df 100644
--- a/arch/x86/power/hibernate_32.c
+++ b/arch/x86/power/hibernate_32.c
@@ -18,7 +18,7 @@
 extern int restore_image(void);
 
 /* References to section boundaries */
-extern const void __nosave_begin, __nosave_end;
+extern __visible const void __nosave_begin, __nosave_end;
 
 /* Pointer to the temporary resume page tables */
 pgd_t *resume_pg_dir;
diff --git a/arch/x86/um/vdso/vma.c b/arch/x86/um/vdso/vma.c
index af91901..a09f903 100644
--- a/arch/x86/um/vdso/vma.c
+++ b/arch/x86/um/vdso/vma.c
@@ -16,7 +16,7 @@ unsigned int __read_mostly vdso_enabled = 1;
 unsigned long um_vdso_addr;
 
 extern unsigned long task_size;
-extern char vdso_start[], vdso_end[];
+extern __visible char vdso_start[], vdso_end[];
 
 static struct page **vdsop;
 
diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
index 00aaf04..fe08e2b 100644
--- a/arch/x86/vdso/vma.c
+++ b/arch/x86/vdso/vma.c
@@ -18,15 +18,15 @@
 
 unsigned int __read_mostly vdso_enabled = 1;
 
-extern char vdso_start[], vdso_end[];
-extern unsigned short vdso_sync_cpuid;
+extern __visible char vdso_start[], vdso_end[];
+extern __visible unsigned short vdso_sync_cpuid;
 
-extern struct page *vdso_pages[];
+extern __visible struct page *vdso_pages[];
 static unsigned vdso_size;
 
 #ifdef CONFIG_X86_X32_ABI
-extern char vdsox32_start[], vdsox32_end[];
-extern struct page *vdsox32_pages[];
+extern __visible char vdsox32_start[], vdsox32_end[];
+extern __visible struct page *vdsox32_pages[];
 static unsigned vdsox32_size;
 
 static void __init patch_vdsox32(void *vdso, size_t len)
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 63/74] Kbuild, lto: Print correct info messages for vmlinux link

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

With LTO the tmp_vmlinux builds can take very long. Have own messages
to print so that it's clear what's going on. Previously the vmlinux
link would really happen during "LD init/built-in.o"

Also print separate messages for all the vmlinux link steps.

Signed-off-by: Andi Kleen 
---
 scripts/link-vmlinux.sh |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 4629038..a05c49c 100644
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -176,10 +176,12 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
kallsyms_vmlinux=.tmp_vmlinux2
 
# step 1
+   info LDFINAL .tmp_vmlinux1
vmlinux_link "" .tmp_vmlinux1
kallsyms .tmp_vmlinux1 .tmp_kallsyms1.o
 
# step 2
+   info LDFINAL .tmp_vmlinux2
vmlinux_link .tmp_kallsyms1.o .tmp_vmlinux2
kallsyms .tmp_vmlinux2 .tmp_kallsyms2.o
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/74] sections: Add __visible to ia64 sections

2012-08-18 Thread Andi Kleen
From: Andi Kleen 

Signed-off-by: Andi Kleen 
---
 arch/ia64/include/asm/sections.h |   26 +-
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/ia64/include/asm/sections.h b/arch/ia64/include/asm/sections.h
index 1a873b3..68b8f3a 100644
--- a/arch/ia64/include/asm/sections.h
+++ b/arch/ia64/include/asm/sections.h
@@ -10,21 +10,21 @@
 #include 
 #include 
 
-extern char __per_cpu_start[], __per_cpu_end[], __phys_per_cpu_start[];
+extern __visible char __per_cpu_start[], __per_cpu_end[], 
__phys_per_cpu_start[];
 #ifdef CONFIG_SMP
-extern char __cpu0_per_cpu[];
+extern __visible char __cpu0_per_cpu[];
 #endif
-extern char __start___vtop_patchlist[], __end___vtop_patchlist[];
-extern char __start___rse_patchlist[], __end___rse_patchlist[];
-extern char __start___mckinley_e9_bundles[], __end___mckinley_e9_bundles[];
-extern char __start___phys_stack_reg_patchlist[], 
__end___phys_stack_reg_patchlist[];
-extern char __start_gate_section[];
-extern char __start_gate_mckinley_e9_patchlist[], 
__end_gate_mckinley_e9_patchlist[];
-extern char __start_gate_vtop_patchlist[], __end_gate_vtop_patchlist[];
-extern char __start_gate_fsyscall_patchlist[], __end_gate_fsyscall_patchlist[];
-extern char __start_gate_brl_fsys_bubble_down_patchlist[], 
__end_gate_brl_fsys_bubble_down_patchlist[];
-extern char __start_unwind[], __end_unwind[];
-extern char __start_ivt_text[], __end_ivt_text[];
+extern __visible char __start___vtop_patchlist[], __end___vtop_patchlist[];
+extern __visible char __start___rse_patchlist[], __end___rse_patchlist[];
+extern __visible char __start___mckinley_e9_bundles[], 
__end___mckinley_e9_bundles[];
+extern __visible char __start___phys_stack_reg_patchlist[], 
__end___phys_stack_reg_patchlist[];
+extern __visible char __start_gate_section[];
+extern __visible char __start_gate_mckinley_e9_patchlist[], 
__end_gate_mckinley_e9_patchlist[];
+extern __visible char __start_gate_vtop_patchlist[], 
__end_gate_vtop_patchlist[];
+extern __visible char __start_gate_fsyscall_patchlist[], 
__end_gate_fsyscall_patchlist[];
+extern __visible char __start_gate_brl_fsys_bubble_down_patchlist[], 
__end_gate_brl_fsys_bubble_down_patchlist[];
+extern __visible char __start_unwind[], __end_unwind[];
+extern __visible char __start_ivt_text[], __end_ivt_text[];
 
 #undef dereference_function_descriptor
 static inline void *dereference_function_descriptor(void *ptr)
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ext4: fix trivial typo in the comment for extents.c/ext4_split_unwritten_extents

2012-08-18 Thread Theodore Ts'o
On Sun, Jul 15, 2012 at 11:41:08AM +0800, Wang Sheng-Hui wrote:
> Put the sign '/' to the right position.
> 
> Signed-off-by: Wang Sheng-Hui 

Applied, thanks.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 04/11] x86/microcode_core_early.c: Define interfaces for early load ucode

2012-08-18 Thread Yu, Fenghua
> -Original Message-
> From: Henrique de Moraes Holschuh [mailto:h...@hmh.eng.br]
> Sent: Saturday, August 18, 2012 3:45 PM
> To: Yu, Fenghua
> Cc: H Peter Anvin; Ingo Molnar; Thomas Gleixner; Mallick, Asit K;
> Tigran Aivazian; Andreas Herrmann; Borislav Petkov; linux-kernel; x86
> Subject: Re: [PATCH 04/11] x86/microcode_core_early.c: Define
> interfaces for early load ucode
> 
> On Sat, 18 Aug 2012, Fenghua Yu wrote:
> > +   char ucode_name[] =
> "kernel/x86/microcode/GenuineIntel/microcode.hex";
> 
> Why name it ".hex" when you're loading binary data?  I suggest ".bin".
> It
> is confusing to have .hex there, since you're not dealing with the
> Intel HEX
> format, nor anything text-like.
> 
> > +void __init load_ucode_bsp(char *real_mode_data)
> > +{
> > +   u64 ramdisk_image, ramdisk_size, ramdisk_end;
> > +   unsigned long initrd_start, initrd_end;
> > +   struct boot_params *boot_params;
> > +
> > +   boot_params = (struct boot_params *)real_mode_data;
> > +   ramdisk_image = boot_params->hdr.ramdisk_image;
> > +   ramdisk_size  = boot_params->hdr.ramdisk_size;
> > +
> > +#ifdef CONFIG_X86_64
> > +   ramdisk_end  = PAGE_ALIGN(ramdisk_image + ramdisk_size);
> > +   initrd_start = ramdisk_image + PAGE_OFFSET;
> > +#else
> > +   ramdisk_end  = ramdisk_image + ramdisk_size;
> > +   initrd_start = ramdisk_image;
> > +#endif
> > +   initrd_end = initrd_start + ramdisk_size;
> > +
> > +   /*
> > +* It's early to get CPU vendor info at this point.
> > +* By searching initrd to find right name for vendor's microcode,
> > +* it's relative easier to get CPU vendor info.
> > +*/
> > +   if (find_ucode_intel(initrd_start, initrd_end) == UCODE_OK)
> > +   load_ucode_intel_bsp(real_mode_data);
> > +}
> 
> I'd say something down the load_ucode_intel_bsp() chain better check
> the CPU
> vendor to make sure the Intel driver won't attempt to load microcode on
> some
> other vendor's processor.
> 
> Or are cpu signatures a global namespace and x86 cpu vendors make sure
> (past, present and future) to never use the same cpu signature as
> someone
> else is going to use?  Anyway, it would still might be a good thing to
> do
> the vendor check somewhere to avoid wasting time going over every
> microcode
> of the wrong vendor on generic boot images that have both AMD and Intel
> microcode.
> 

In this early phase, detecting vendor in initrd is much simpler code. 
Otherwise, detecting vendor by cpuid (and without cpuid) needs similar but 
different code as existing functions and coding would be awkward. 

I fully thought and agreed the usage complexity you describe here. It might be 
good thing to do a bit ugly but more practical coding here.

Thanks.

-Fenghua
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RESEND] Ext4: No need to add inode to orphan list during hole punch

2012-08-18 Thread Theodore Ts'o
On Wed, Jul 25, 2012 at 07:53:34PM +0530, Ashish Sangwan wrote:
> While performing punch hole for an inode, i_disksize is not changed.
> So, there is no need to add the inode to orphan list.
> 
> Signed-off-by: Ashish Sangwan 
> Signed-off-by: Namjae Jeon 

Thanks, applied.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit

2012-08-18 Thread Fengguang Wu
On Sat, Aug 18, 2012 at 05:49:21AM -0400, Namjae Jeon wrote:
> unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long 
> dirty)
> 
> Above function return type is unsigned long, but return value is
> kept in "u64 bdi_dirty".
> It can return incorrect value by type casting.

I don't see how the cast can return wrong value.
The u64 is necessary for the intermediate calculations.

Thanks,
Fengguang

> Signed-off-by: Namjae Jeon 
> ---
>  mm/page-writeback.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 49133b6..73a7a06 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -546,7 +546,7 @@ static unsigned long hard_dirty_limit(unsigned long 
> thresh)
>   */
>  unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long 
> dirty)
>  {
> - u64 bdi_dirty;
> + unsigned long bdi_dirty;
>   long numerator, denominator;
>  
>   /*
> -- 
> 1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/3] writeback: change nr_pages_dirtied argument into local variable

2012-08-18 Thread Fengguang Wu
On Sat, Aug 18, 2012 at 05:48:29AM -0400, Namjae Jeon wrote:
> There is no reason nr_pages_dirtied is argument anymore.
> because nr_pages_dirtied value from caller is not used in
> balance_dirty_pages_ratelimited_nr function.

Looks good to me. If the fs developers don't have problems with this,
I'll apply it to the writeback tree.

Thanks,
Fengguang

> Signed-off-by: Namjae Jeon 
> Signed-off-by: Vivek Trivedi 
> ---
>  fs/btrfs/disk-io.c|8 
>  fs/btrfs/file.c   |3 +--
>  fs/btrfs/ioctl.c  |2 +-
>  fs/ocfs2/file.c   |5 +
>  fs/splice.c   |5 +
>  include/linux/writeback.h |9 +
>  mm/page-writeback.c   |   11 +--
>  7 files changed, 14 insertions(+), 29 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 62e0caf..10b6128 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3344,8 +3344,8 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, 
> unsigned long nr)
>   num_dirty = root->fs_info->dirty_metadata_bytes;
>  
>   if (num_dirty > thresh) {
> - balance_dirty_pages_ratelimited_nr(
> -root->fs_info->btree_inode->i_mapping, 1);
> + balance_dirty_pages_ratelimited(
> +root->fs_info->btree_inode->i_mapping);
>   }
>   return;
>  }
> @@ -3365,8 +3365,8 @@ void __btrfs_btree_balance_dirty(struct btrfs_root 
> *root, unsigned long nr)
>   num_dirty = root->fs_info->dirty_metadata_bytes;
>  
>   if (num_dirty > thresh) {
> - balance_dirty_pages_ratelimited_nr(
> -root->fs_info->btree_inode->i_mapping, 1);
> + balance_dirty_pages_ratelimited(
> +root->fs_info->btree_inode->i_mapping);
>   }
>   return;
>  }
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index f6b40e8..0dae684 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -1314,8 +1314,7 @@ static noinline ssize_t __btrfs_buffered_write(struct 
> file *file,
>  
>   cond_resched();
>  
> - balance_dirty_pages_ratelimited_nr(inode->i_mapping,
> -dirty_pages);
> + balance_dirty_pages_ratelimited(inode->i_mapping);
>   if (dirty_pages < (root->leafsize >> PAGE_CACHE_SHIFT) + 1)
>   btrfs_btree_balance_dirty(root, 1);
>  
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 7bb7556..df2e9fb 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1199,7 +1199,7 @@ int btrfs_defrag_file(struct inode *inode, struct file 
> *file,
>   }
>  
>   defrag_count += ret;
> - balance_dirty_pages_ratelimited_nr(inode->i_mapping, ret);
> + balance_dirty_pages_ratelimited(inode->i_mapping);
>   mutex_unlock(>i_mutex);
>  
>   if (newer_than) {
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 46a1f6d..a83c964 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -2515,18 +2515,15 @@ static ssize_t ocfs2_file_splice_write(struct 
> pipe_inode_info *pipe,
>   ret = sd.num_spliced;
>  
>   if (ret > 0) {
> - unsigned long nr_pages;
>   int err;
>  
> - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
> -
>   err = generic_write_sync(out, *ppos, ret);
>   if (err)
>   ret = err;
>   else
>   *ppos += ret;
>  
> - balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
> + balance_dirty_pages_ratelimited(mapping);
>   }
>  
>   return ret;
> diff --git a/fs/splice.c b/fs/splice.c
> index 41514dd..36b6c17 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -1024,17 +1024,14 @@ generic_file_splice_write(struct pipe_inode_info 
> *pipe, struct file *out,
>   ret = sd.num_spliced;
>  
>   if (ret > 0) {
> - unsigned long nr_pages;
>   int err;
>  
> - nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
> -
>   err = generic_write_sync(out, *ppos, ret);
>   if (err)
>   ret = err;
>   else
>   *ppos += ret;
> - balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
> + balance_dirty_pages_ratelimited(mapping);
>   }
>   sb_end_write(inode->i_sb);
>  
> diff --git a/include/linux/writeback.h b/include/linux/writeback.h
> index 50c3e8f..b82a83a 100644
> --- a/include/linux/writeback.h
> +++ b/include/linux/writeback.h
> @@ -161,14 +161,7 @@ void __bdi_update_bandwidth(struct backing_dev_info *bdi,
>   unsigned long start_time);
>  
>  void page_writeback_init(void);
> -void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
> -   

Re: [PATCH 01/31] Disable const sections for PA-RISC

2012-08-18 Thread Andi Kleen
> > +config BROKEN_RODATA
> > +   bool
> > +   default y
> 
> Could you please change this so we have a commonly defined HAVE_BROKEN_RODATA
> symbol. Then arch's that have broken RO data can select this symbol.
> If we experience tomorrow that sparc have the same issue then with
> this patch sparc has to create a local definition of this symbol.

Here's an updated patch with the config placed in init/Kconfig.
I'm not going to repost the whole series.

-Andi

---

Disable const sections for PA-RISC v2

The PA-RISC tool chain seems to have some problem with correct read/write
attributes on sections. This causes problems when the const sections
are fixed up for other architecture to only contain truly read-only
data.

Disable const sections for PA-RISC

This can cause a bit of noise with modpost.

v2: Move config to init/Kconfig
Cc: james.bottom...@hansenpartnership.com
Signed-off-by: Andi Kleen 
---
 arch/parisc/Kconfig  |1 +
 include/linux/init.h |   27 +++
 init/Kconfig |6 ++
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 3ff21b5..77f9c81 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -19,6 +19,7 @@ config PARISC
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select GENERIC_SMP_IDLE_THREAD
select GENERIC_STRNCPY_FROM_USER
+   select BROKEN_RODATA
 
help
  The PA-RISC microprocessor is designed by Hewlett-Packard and used
diff --git a/include/linux/init.h b/include/linux/init.h
index 5e664f6..c2f06b3 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -43,10 +43,21 @@
discard it in modules) */
 #define __init __section(.init.text) __cold notrace
 #define __initdata __section(.init.data)
-#define __initconst__section(.init.rodata)
+#define __initconst__constsection(.init.rodata)
 #define __exitdata __section(.exit.data)
 #define __exit_call__used __section(.exitcall.exit)
 
+/* 
+ * Some architecture have tool chains which do not handle rodata attributes
+ * correctly. For those disable special sections for const, so that other
+ * architectures can annotate correctly.
+ */
+#ifdef CONFIG_BROKEN_RODATA
+#define __constsection(x)
+#else
+#define __constsection(x) __section(x)
+#endif
+
 /*
  * modpost check for section mismatches during the kernel build.
  * A section mismatch happens when there are references from a
@@ -66,7 +77,7 @@
  */
 #define __ref__section(.ref.text) noinline
 #define __refdata__section(.ref.data)
-#define __refconst   __section(.ref.rodata)
+#define __refconst   __constsection(.ref.rodata)
 
 /* compatibility defines */
 #define __init_refok __ref
@@ -85,26 +96,26 @@
 /* Used for HOTPLUG */
 #define __devinit__section(.devinit.text) __cold notrace
 #define __devinitdata__section(.devinit.data)
-#define __devinitconst   __section(.devinit.rodata)
+#define __devinitconst   __constsection(.devinit.rodata)
 #define __devexit__section(.devexit.text) __exitused __cold notrace
 #define __devexitdata__section(.devexit.data)
-#define __devexitconst   __section(.devexit.rodata)
+#define __devexitconst   __constsection(.devexit.rodata)
 
 /* Used for HOTPLUG_CPU */
 #define __cpuinit__section(.cpuinit.text) __cold notrace
 #define __cpuinitdata__section(.cpuinit.data)
-#define __cpuinitconst   __section(.cpuinit.rodata)
+#define __cpuinitconst   __constsection(.cpuinit.rodata)
 #define __cpuexit__section(.cpuexit.text) __exitused __cold notrace
 #define __cpuexitdata__section(.cpuexit.data)
-#define __cpuexitconst   __section(.cpuexit.rodata)
+#define __cpuexitconst   __constsection(.cpuexit.rodata)
 
 /* Used for MEMORY_HOTPLUG */
 #define __meminit__section(.meminit.text) __cold notrace
 #define __meminitdata__section(.meminit.data)
-#define __meminitconst   __section(.meminit.rodata)
+#define __meminitconst   __constsection(.meminit.rodata)
 #define __memexit__section(.memexit.text) __exitused __cold notrace
 #define __memexitdata__section(.memexit.data)
-#define __memexitconst   __section(.memexit.rodata)
+#define __memexitconst   __constsection(.memexit.rodata)
 
 /* For assembly routines */
 #define __HEAD .section".head.text","ax"
diff --git a/init/Kconfig b/init/Kconfig
index af6c7f8..a8785db 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1612,4 +1612,10 @@ config PADATA
depends on SMP
bool
 
+# Can be selected by architectures with broken toolchains
+# that get confused by correct const<->read_only section
+# mappings
+config BROKEN_RODATA
+   bool
+
 source "kernel/Kconfig.locks"
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 14/31] sections: Fix section conflicts in drivers/hwmon

2012-08-18 Thread Andi Kleen
On Sat, Aug 18, 2012 at 04:23:04PM -0700, Guenter Roeck wrote:
> On Sat, Aug 18, 2012 at 10:30:05AM -0700, Andi Kleen wrote:
> > From: Andi Kleen 
> > 
> > Signed-off-by: Andi Kleen 
> 
> Applied.
> 

Thanks.

> Looks like you did not include maintainers and/or subject mailing lists in 
> your
> patch series, so I guess you won't get much feedback.

Tree sweeps like this normally don't go through individual mainainers, it's just
not practical.

-Andi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 01/16] hashtable: introduce a small and naive hashtable

2012-08-18 Thread Sasha Levin
This hashtable implementation is using hlist buckets to provide a simple
hashtable to prevent it from getting reimplemented all over the kernel.

Signed-off-by: Sasha Levin 
---
 include/linux/hashtable.h |  284 +
 1 files changed, 284 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/hashtable.h

diff --git a/include/linux/hashtable.h b/include/linux/hashtable.h
new file mode 100644
index 000..b18827a
--- /dev/null
+++ b/include/linux/hashtable.h
@@ -0,0 +1,284 @@
+/*
+ * Hash table implementation
+ * (C) 2012  Sasha Levin 
+ */
+
+#ifndef _LINUX_HASHTABLE_H
+#define _LINUX_HASHTABLE_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DEFINE_HASHTABLE(name, bits)   \
+   struct hlist_head name[HASH_SIZE(bits)];
+
+#define HASH_SIZE(bits) (1 << (bits))
+#define HASH_BITS(name) (ilog2(ARRAY_SIZE(name)))
+
+/* Use hash_32 when possible to allow for fast 32bit hashing in 64bit kernels. 
*/
+#define hash_min(val, bits) ((sizeof(val)==4) ? hash_32((val), (bits)) : 
hash_long((val), (bits)))
+
+/**
+ * hash_init_size - initialize a hash table
+ * @hashtable: hashtable to be initialized
+ * @bits: bit count of hashing function
+ *
+ * Initializes a hash table with 2**bits buckets.
+ */
+static inline void hash_init_size(struct hlist_head *hashtable, int bits)
+{
+   int i;
+
+   for (i = 0; i < HASH_SIZE(bits); i++)
+   INIT_HLIST_HEAD(hashtable + i);
+}
+
+/**
+ * hash_init - initialize a hash table
+ * @hashtable: hashtable to be initialized
+ *
+ * Calculates the size of the hashtable from the given parameter, otherwise
+ * same as hash_init_size.
+ */
+#define hash_init(name) hash_init_size(name, HASH_BITS(name))
+
+/**
+ * hash_add_size - add an object to a hashtable
+ * @hashtable: hashtable to add to
+ * @bits: bit count used for hashing
+ * @node: the  hlist_node of the object to be added
+ * @key: the key of the object to be added
+ */
+#define hash_add_size(hashtable, bits, node, key)  
\
+   hlist_add_head(node, [hash_min(key, bits)]);
+
+/**
+ * hash_add - add an object to a hashtable
+ * @hashtable: hashtable to add to
+ * @node: the  hlist_node of the object to be added
+ * @key: the key of the object to be added
+ */
+#define hash_add(hashtable, node, key) 
\
+   hash_add_size(hashtable, HASH_BITS(hashtable), node, key)
+
+/**
+ * hash_add_rcu_size - add an object to a rcu enabled hashtable
+ * @hashtable: hashtable to add to
+ * @bits: bit count used for hashing
+ * @node: the  hlist_node of the object to be added
+ * @key: the key of the object to be added
+ */
+#define hash_add_rcu_size(hashtable, bits, node, key)  
\
+   hlist_add_head_rcu(node, [hash_min(key, bits)]);
+
+/**
+ * hash_add_rcu - add an object to a rcu enabled hashtable
+ * @hashtable: hashtable to add to
+ * @node: the  hlist_node of the object to be added
+ * @key: the key of the object to be added
+ */
+#define hash_add_rcu(hashtable, node, key) 
\
+   hash_add_rcu_size(hashtable, HASH_BITS(hashtable), node, key)
+
+/**
+ * hash_hashed - check whether an object is in any hashtable
+ * @node: the  hlist_node of the object to be checked
+ */
+#define hash_hashed(node) (!hlist_unhashed(node))
+
+/**
+ * hash_empty_size - check whether a hashtable is empty
+ * @hashtable: hashtable to check
+ * @bits: bit count used for hashing
+ */
+static inline bool hash_empty_size(struct hlist_head *hashtable, int bits)
+{
+   int i;
+
+   for (i = 0; i < HASH_SIZE(bits); i++)
+   if (!hlist_empty([i]))
+   return false;
+
+   return true;
+}
+
+/**
+ * hash_empty - check whether a hashtable is empty
+ * @hashtable: hashtable to check
+ */
+#define hash_empty(name) hash_empty_size(name, HASH_BITS(name))
+
+/**
+ * hash_del - remove an object from a hashtable
+ * @node:  hlist_node of the object to remove
+ */
+static inline void hash_del(struct hlist_node *node)
+{
+   hlist_del_init(node);
+}
+
+/**
+ * hash_del_rcu - remove an object from a rcu enabled hashtable
+ * @node:  hlist_node of the object to remove
+ */
+static inline void hash_del_rcu(struct hlist_node *node)
+{
+   hlist_del_init_rcu(node);
+}
+
+/**
+ * hash_for_each_size - iterate over a hashtable
+ * @name: hashtable to iterate
+ * @bits: bit count of hashing function of the hashtable
+ * @bkt: integer to use as bucket loop cursor
+ * @node: the  list_head to use as a loop cursor for each bucket
+ * @obj: the type * to use as a loop cursor for each bucket
+ * @member: the name of the hlist_node within the struct
+ */
+#define hash_for_each_size(name, bits, bkt, node, obj, member) 
\
+   for (bkt = 0; bkt < HASH_SIZE(bits); bkt++) 
\
+   hlist_for_each_entry(obj, node, [bkt], member)
+
+/**
+ 

[PATCH v2 04/16] workqueue: use new hashtable implementation

2012-08-18 Thread Sasha Levin
Switch workqueues to use the new hashtable implementation. This reduces the 
amount of
generic unrelated code in the workqueues.

Signed-off-by: Sasha Levin 
---
 kernel/workqueue.c |   86 +---
 1 files changed, 15 insertions(+), 71 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 11723c5..fca751e 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "workqueue_sched.h"
 
@@ -82,8 +83,6 @@ enum {
NR_WORKER_POOLS = 2,/* # worker pools per gcwq */
 
BUSY_WORKER_HASH_ORDER  = 6,/* 64 pointers */
-   BUSY_WORKER_HASH_SIZE   = 1 << BUSY_WORKER_HASH_ORDER,
-   BUSY_WORKER_HASH_MASK   = BUSY_WORKER_HASH_SIZE - 1,
 
MAX_IDLE_WORKERS_RATIO  = 4,/* 1/4 of busy can be idle */
IDLE_WORKER_TIMEOUT = 300 * HZ, /* keep idle ones for 5 mins */
@@ -180,7 +179,7 @@ struct global_cwq {
unsigned intflags;  /* L: GCWQ_* flags */
 
/* workers are chained either in busy_hash or pool idle_list */
-   struct hlist_head   busy_hash[BUSY_WORKER_HASH_SIZE];
+   DEFINE_HASHTABLE(busy_hash, BUSY_WORKER_HASH_ORDER);
/* L: hash of busy workers */
 
struct worker_pool  pools[2];   /* normal and highpri pools */
@@ -288,8 +287,7 @@ EXPORT_SYMBOL_GPL(system_nrt_freezable_wq);
 (pool) < &(gcwq)->pools[NR_WORKER_POOLS]; (pool)++)
 
 #define for_each_busy_worker(worker, i, pos, gcwq) \
-   for (i = 0; i < BUSY_WORKER_HASH_SIZE; i++) \
-   hlist_for_each_entry(worker, pos, >busy_hash[i], hentry)
+   hash_for_each(gcwq->busy_hash, i, pos, worker, hentry)
 
 static inline int __next_gcwq_cpu(int cpu, const struct cpumask *mask,
  unsigned int sw)
@@ -845,63 +843,6 @@ static inline void worker_clr_flags(struct worker *worker, 
unsigned int flags)
 }
 
 /**
- * busy_worker_head - return the busy hash head for a work
- * @gcwq: gcwq of interest
- * @work: work to be hashed
- *
- * Return hash head of @gcwq for @work.
- *
- * CONTEXT:
- * spin_lock_irq(gcwq->lock).
- *
- * RETURNS:
- * Pointer to the hash head.
- */
-static struct hlist_head *busy_worker_head(struct global_cwq *gcwq,
-  struct work_struct *work)
-{
-   const int base_shift = ilog2(sizeof(struct work_struct));
-   unsigned long v = (unsigned long)work;
-
-   /* simple shift and fold hash, do we need something better? */
-   v >>= base_shift;
-   v += v >> BUSY_WORKER_HASH_ORDER;
-   v &= BUSY_WORKER_HASH_MASK;
-
-   return >busy_hash[v];
-}
-
-/**
- * __find_worker_executing_work - find worker which is executing a work
- * @gcwq: gcwq of interest
- * @bwh: hash head as returned by busy_worker_head()
- * @work: work to find worker for
- *
- * Find a worker which is executing @work on @gcwq.  @bwh should be
- * the hash head obtained by calling busy_worker_head() with the same
- * work.
- *
- * CONTEXT:
- * spin_lock_irq(gcwq->lock).
- *
- * RETURNS:
- * Pointer to worker which is executing @work if found, NULL
- * otherwise.
- */
-static struct worker *__find_worker_executing_work(struct global_cwq *gcwq,
-  struct hlist_head *bwh,
-  struct work_struct *work)
-{
-   struct worker *worker;
-   struct hlist_node *tmp;
-
-   hlist_for_each_entry(worker, tmp, bwh, hentry)
-   if (worker->current_work == work)
-   return worker;
-   return NULL;
-}
-
-/**
  * find_worker_executing_work - find worker which is executing a work
  * @gcwq: gcwq of interest
  * @work: work to find worker for
@@ -920,8 +861,14 @@ static struct worker *__find_worker_executing_work(struct 
global_cwq *gcwq,
 static struct worker *find_worker_executing_work(struct global_cwq *gcwq,
 struct work_struct *work)
 {
-   return __find_worker_executing_work(gcwq, busy_worker_head(gcwq, work),
-   work);
+   struct worker *worker;
+   struct hlist_node *tmp;
+
+   hash_for_each_possible(gcwq->busy_hash, worker, tmp, hentry, (unsigned 
long)work)
+   if (worker->current_work == work)
+   return worker;
+
+   return NULL;
 }
 
 /**
@@ -2120,7 +2067,6 @@ __acquires(>lock)
struct cpu_workqueue_struct *cwq = get_work_cwq(work);
struct worker_pool *pool = worker->pool;
struct global_cwq *gcwq = pool->gcwq;
-   struct hlist_head *bwh = busy_worker_head(gcwq, work);
bool cpu_intensive = cwq->wq->flags & WQ_CPU_INTENSIVE;
work_func_t f = work->func;
int work_color;
@@ -2152,7 +2098,7 @@ 

[PATCH v2 02/16] userns: use new hashtable implementation

2012-08-18 Thread Sasha Levin
Switch to using the new hashtable implementation to store user structs.
This reduces the amount of generic unrelated code in kernel/user.c.

Signed-off-by: Sasha Levin 
---
 kernel/user.c |   33 +
 1 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/kernel/user.c b/kernel/user.c
index b815fef..d10c484 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * userns count is 1 for root user, 1 for init_uts_ns,
@@ -52,13 +53,9 @@ EXPORT_SYMBOL_GPL(init_user_ns);
  */
 
 #define UIDHASH_BITS   (CONFIG_BASE_SMALL ? 3 : 7)
-#define UIDHASH_SZ (1 << UIDHASH_BITS)
-#define UIDHASH_MASK   (UIDHASH_SZ - 1)
-#define __uidhashfn(uid)   (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
-#define uidhashentry(uid)  (uidhash_table + __uidhashfn((__kuid_val(uid
 
 static struct kmem_cache *uid_cachep;
-struct hlist_head uidhash_table[UIDHASH_SZ];
+static DEFINE_HASHTABLE(uidhash_table, UIDHASH_BITS)
 
 /*
  * The uidhash_lock is mostly taken from process context, but it is
@@ -84,22 +81,22 @@ struct user_struct root_user = {
 /*
  * These routines must be called with the uidhash spinlock held!
  */
-static void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent)
+static void uid_hash_insert(struct user_struct *up)
 {
-   hlist_add_head(>uidhash_node, hashent);
+   hash_add(uidhash_table, >uidhash_node, __kuid_val(up->uid));
 }
 
 static void uid_hash_remove(struct user_struct *up)
 {
-   hlist_del_init(>uidhash_node);
+   hash_del(>uidhash_node);
 }
 
-static struct user_struct *uid_hash_find(kuid_t uid, struct hlist_head 
*hashent)
+static struct user_struct *uid_hash_find(kuid_t uid)
 {
struct user_struct *user;
struct hlist_node *h;
 
-   hlist_for_each_entry(user, h, hashent, uidhash_node) {
+   hash_for_each_possible(uidhash_table, user, h, uidhash_node, 
__kuid_val(uid)) {
if (uid_eq(user->uid, uid)) {
atomic_inc(>__count);
return user;
@@ -135,7 +132,7 @@ struct user_struct *find_user(kuid_t uid)
unsigned long flags;
 
spin_lock_irqsave(_lock, flags);
-   ret = uid_hash_find(uid, uidhashentry(uid));
+   ret = uid_hash_find(uid);
spin_unlock_irqrestore(_lock, flags);
return ret;
 }
@@ -156,11 +153,10 @@ void free_uid(struct user_struct *up)
 
 struct user_struct *alloc_uid(kuid_t uid)
 {
-   struct hlist_head *hashent = uidhashentry(uid);
struct user_struct *up, *new;
 
spin_lock_irq(_lock);
-   up = uid_hash_find(uid, hashent);
+   up = uid_hash_find(uid);
spin_unlock_irq(_lock);
 
if (!up) {
@@ -176,13 +172,13 @@ struct user_struct *alloc_uid(kuid_t uid)
 * on adding the same user already..
 */
spin_lock_irq(_lock);
-   up = uid_hash_find(uid, hashent);
+   up = uid_hash_find(uid);
if (up) {
key_put(new->uid_keyring);
key_put(new->session_keyring);
kmem_cache_free(uid_cachep, new);
} else {
-   uid_hash_insert(new, hashent);
+   uid_hash_insert(new);
up = new;
}
spin_unlock_irq(_lock);
@@ -196,17 +192,14 @@ out_unlock:
 
 static int __init uid_cache_init(void)
 {
-   int n;
-
uid_cachep = kmem_cache_create("uid_cache", sizeof(struct user_struct),
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
 
-   for(n = 0; n < UIDHASH_SZ; ++n)
-   INIT_HLIST_HEAD(uidhash_table + n);
+   hash_init(uidhash_table);
 
/* Insert the root user immediately (init already runs as root) */
spin_lock_irq(_lock);
-   uid_hash_insert(_user, uidhashentry(GLOBAL_ROOT_UID));
+   uid_hash_insert(_user);
spin_unlock_irq(_lock);
 
return 0;
-- 
1.7.8.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 16/16] tracing output: use new hashtable implementation

2012-08-18 Thread Sasha Levin
Switch tracing to use the new hashtable implementation. This reduces the amount 
of
generic unrelated code in the tracing module.

Signed-off-by: Sasha Levin 
---
 kernel/trace/trace_output.c |   20 
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 123b189..1324c1a 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -8,15 +8,15 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "trace_output.h"
 
-/* must be a power of 2 */
-#define EVENT_HASHSIZE 128
+#define EVENT_HASH_BITS7
 
 DECLARE_RWSEM(trace_event_mutex);
 
-static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;
+static DEFINE_HASHTABLE(event_hash, EVENT_HASH_BITS);
 
 static int next_event_type = __TRACE_LAST_TYPE + 1;
 
@@ -712,11 +712,8 @@ struct trace_event *ftrace_find_event(int type)
 {
struct trace_event *event;
struct hlist_node *n;
-   unsigned key;
 
-   key = type & (EVENT_HASHSIZE - 1);
-
-   hlist_for_each_entry(event, n, _hash[key], node) {
+   hash_for_each_possible(event_hash, event, n, node, type) {
if (event->type == type)
return event;
}
@@ -781,7 +778,6 @@ void trace_event_read_unlock(void)
  */
 int register_ftrace_event(struct trace_event *event)
 {
-   unsigned key;
int ret = 0;
 
down_write(_event_mutex);
@@ -833,9 +829,7 @@ int register_ftrace_event(struct trace_event *event)
if (event->funcs->binary == NULL)
event->funcs->binary = trace_nop_print;
 
-   key = event->type & (EVENT_HASHSIZE - 1);
-
-   hlist_add_head(>node, _hash[key]);
+   hash_add(event_hash, >node, event->type);
 
ret = event->type;
  out:
@@ -850,7 +844,7 @@ EXPORT_SYMBOL_GPL(register_ftrace_event);
  */
 int __unregister_ftrace_event(struct trace_event *event)
 {
-   hlist_del(>node);
+   hash_del(>node);
list_del(>list);
return 0;
 }
@@ -1323,6 +1317,8 @@ __init static int init_events(void)
}
}
 
+   hash_init(event_hash);
+
return 0;
 }
 early_initcall(init_events);
-- 
1.7.8.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   >