Linus,

Russell King was reporting lots of warnings when he compiled his kernel
with ftrace enabled. With some investigation it was discovered that it
was his compile setup. He was using ccache with hard links, which allowed
recordmcount to process the same .o twice. When this happens, recordmcount
will detect that it was already done and give a warning about it.

Russell fixed this by having recordmcount detect that the object file
has more than one hard link, and if it does, it unlinks the object file
after it maps it and processes then. This appears to fix the issue.


Please pull the latest trace-v4.4-rc4 tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.4-rc4

Tag SHA1: 4a56e8c7c0562310d74910b17429134d44418cc7
Head SHA1: 420cbb014db5594f8e503fc578fdd146a458f92c


Russell King (1):
      scripts: recordmcount: break hardlinks

----
 scripts/recordmcount.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---------------------------
commit 420cbb014db5594f8e503fc578fdd146a458f92c
Author: Russell King <[email protected]>
Date:   Fri Dec 11 12:09:03 2015 +0000

    scripts: recordmcount: break hardlinks
    
    recordmcount edits the file in-place, which can cause problems when
    using ccache in hardlink mode.  Arrange for recordmcount to break a
    hardlinked object.
    
    Link: http://lkml.kernel.org/r/[email protected]
    
    Cc: [email protected] # 2.6.37+
    Signed-off-by: Russell King <[email protected]>
    Signed-off-by: Steven Rostedt <[email protected]>

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 698768bdc581..91705ef30402 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -211,6 +211,20 @@ static void *mmap_file(char const *fname)
                addr = umalloc(sb.st_size);
                uread(fd_map, addr, sb.st_size);
        }
+       if (sb.st_nlink != 1) {
+               /* file is hard-linked, break the hard link */
+               close(fd_map);
+               if (unlink(fname) < 0) {
+                       perror(fname);
+                       fail_file();
+               }
+               fd_map = open(fname, O_RDWR | O_CREAT, sb.st_mode);
+               if (fd_map < 0) {
+                       perror(fname);
+                       fail_file();
+               }
+               uwrite(fd_map, addr, sb.st_size);
+       }
        return addr;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to