All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Michal Marek" <mmarek@suse.cz>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>,
	linux-kbuild@vger.kernel.org, "Nicolas Pitre" <nico@fluxnic.net>,
	"Arnd Bergmann" <arnd@arndb.de>, "Måns Rullgård" <mans@mansr.com>
Subject: Re: [PATCH v2 1/2] scripts: Add a recorduidiv program
Date: Tue, 1 Dec 2015 17:10:14 +0000	[thread overview]
Message-ID: <20151201171014.GY8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20151201114929.655433a2@gandalf.local.home>

On Tue, Dec 01, 2015 at 11:49:29AM -0500, Steven Rostedt wrote:
> On Tue, 1 Dec 2015 16:19:44 +0000
> Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
>  
> > They hardly "do nothing", as the (eg) recordmcount plasters the build
> > log with warnings.  A solution to that would be to make recordmcount
> > silent if the section is already present.
> 
> Note, that warning found plenty of bugs when modifications of the build
> system was being done and broke recordmcount.c. I really don't want to
> silent it.
> 
> But for some reason, your build is causing lots of warnings and not for
> others. Perhaps we can add a "SILENT_RECORDMCOUNT" environment variable
> and have it set when something like CCACHE_HARDLINK or whatever is
> causing it to trigger when we don't care.

The case is:

Build 1 runs with CCACHE_HARDLINK enabled.
- Each object ccache creates will be stored in ccache, and hard linked
  into the throw-away object tree.
- recordmcount modifies in-place the object in the object tree, which
  also modifies the object in the ccache repository.

The throw-away object tree is thrown away, and a new tree is created,
and the build re-run.  It doesn't matter what CCACHE options are used,
the effect will now be the same:
- Each "hit" ccache object from the previous build will be linked or
  copied to the new throw-away object tree.
- recordmcount will be re-run on the object, which now contains the
  results of the previous recordmcount in-place modification.  This
  causes recordmcount to issue a warning.

There's two solutions to this: one is to disable CCACHE_HARDLINK for
all kernel builds which use in-place object modification.  The other
solution is to avoid in-place object modification, instead doing a
read-write-rename.

I think I ought to ask another question though, before we decide what
to do.  With recordmcount doing in-place object modification, what
happens if a SIGINT or similar is received half way through the
modification of an object?  I would hope that make would delete the
object and not leave it around.

Another suggestion - maybe recordmcount, which fstat()s the file,
should check the st_nlink before modifying the file, and error out
with a helpful error message telling people not to use hardlinks,
which would stop nasty surprises (and make it a rule that this should
be implemented as a general principle for good build behaviour) - iow,
something like this (untested):

 scripts/recordmcount.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 698768bdc581..bb7589fd7392 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -203,6 +203,10 @@ static void *mmap_file(char const *fname)
 		fprintf(stderr, "not a regular file: %s\n", fname);
 		fail_file();
 	}
+	if (sb.st_nlink != 1) {
+		fprintf(stderr, "file is hard linked: %s\n", fname);
+		fail_file();
+	}
 	addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE,
 		    fd_map, 0);
 	mmap_failed = 0;


-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

WARNING: multiple messages have this Message-ID (diff)
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] scripts: Add a recorduidiv program
Date: Tue, 1 Dec 2015 17:10:14 +0000	[thread overview]
Message-ID: <20151201171014.GY8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20151201114929.655433a2@gandalf.local.home>

On Tue, Dec 01, 2015 at 11:49:29AM -0500, Steven Rostedt wrote:
> On Tue, 1 Dec 2015 16:19:44 +0000
> Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
>  
> > They hardly "do nothing", as the (eg) recordmcount plasters the build
> > log with warnings.  A solution to that would be to make recordmcount
> > silent if the section is already present.
> 
> Note, that warning found plenty of bugs when modifications of the build
> system was being done and broke recordmcount.c. I really don't want to
> silent it.
> 
> But for some reason, your build is causing lots of warnings and not for
> others. Perhaps we can add a "SILENT_RECORDMCOUNT" environment variable
> and have it set when something like CCACHE_HARDLINK or whatever is
> causing it to trigger when we don't care.

The case is:

Build 1 runs with CCACHE_HARDLINK enabled.
- Each object ccache creates will be stored in ccache, and hard linked
  into the throw-away object tree.
- recordmcount modifies in-place the object in the object tree, which
  also modifies the object in the ccache repository.

The throw-away object tree is thrown away, and a new tree is created,
and the build re-run.  It doesn't matter what CCACHE options are used,
the effect will now be the same:
- Each "hit" ccache object from the previous build will be linked or
  copied to the new throw-away object tree.
- recordmcount will be re-run on the object, which now contains the
  results of the previous recordmcount in-place modification.  This
  causes recordmcount to issue a warning.

There's two solutions to this: one is to disable CCACHE_HARDLINK for
all kernel builds which use in-place object modification.  The other
solution is to avoid in-place object modification, instead doing a
read-write-rename.

I think I ought to ask another question though, before we decide what
to do.  With recordmcount doing in-place object modification, what
happens if a SIGINT or similar is received half way through the
modification of an object?  I would hope that make would delete the
object and not leave it around.

Another suggestion - maybe recordmcount, which fstat()s the file,
should check the st_nlink before modifying the file, and error out
with a helpful error message telling people not to use hardlinks,
which would stop nasty surprises (and make it a rule that this should
be implemented as a general principle for good build behaviour) - iow,
something like this (untested):

 scripts/recordmcount.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 698768bdc581..bb7589fd7392 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -203,6 +203,10 @@ static void *mmap_file(char const *fname)
 		fprintf(stderr, "not a regular file: %s\n", fname);
 		fail_file();
 	}
+	if (sb.st_nlink != 1) {
+		fprintf(stderr, "file is hard linked: %s\n", fname);
+		fail_file();
+	}
 	addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE,
 		    fd_map, 0);
 	mmap_failed = 0;


-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2015-12-01 17:10 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 21:51 [PATCH v2 0/2] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Stephen Boyd
2015-11-25 21:51 ` Stephen Boyd
2015-11-25 21:51 ` Stephen Boyd
2015-11-25 21:51 ` [PATCH v2 1/2] scripts: Add a recorduidiv program Stephen Boyd
2015-11-25 21:51   ` Stephen Boyd
2015-11-25 23:47   ` Russell King - ARM Linux
2015-11-25 23:47     ` Russell King - ARM Linux
2015-11-30 15:11     ` Michal Marek
2015-11-30 15:11       ` Michal Marek
2015-11-30 15:32       ` Russell King - ARM Linux
2015-11-30 15:32         ` Russell King - ARM Linux
2015-11-30 15:32         ` Russell King - ARM Linux
2015-11-30 15:40         ` Michal Marek
2015-11-30 15:40           ` Michal Marek
2015-12-01 16:07           ` Michal Marek
2015-12-01 16:07             ` Michal Marek
2015-12-01 16:19             ` Russell King - ARM Linux
2015-12-01 16:19               ` Russell King - ARM Linux
2015-12-01 16:43               ` Michal Marek
2015-12-01 16:43                 ` Michal Marek
2015-12-01 16:49               ` Steven Rostedt
2015-12-01 16:49                 ` Steven Rostedt
2015-12-01 17:10                 ` Russell King - ARM Linux [this message]
2015-12-01 17:10                   ` Russell King - ARM Linux
2015-12-01 17:22                   ` Steven Rostedt
2015-12-01 17:22                     ` Steven Rostedt
2015-12-01 18:16                     ` Russell King - ARM Linux
2015-12-01 18:16                       ` Russell King - ARM Linux
2015-12-01 21:39                       ` Michal Marek
2015-12-01 21:39                         ` Michal Marek
2015-12-02 10:23                       ` Russell King - ARM Linux
2015-12-02 10:23                         ` Russell King - ARM Linux
2015-12-02 14:05                         ` Steven Rostedt
2015-12-02 14:05                           ` Steven Rostedt
2015-12-11 12:09                           ` [PATCH] scripts: recordmcount: break hardlinks Russell King
2015-12-11 12:09                             ` Russell King
2015-12-11 14:31                             ` Steven Rostedt
2015-12-11 14:31                               ` Steven Rostedt
2015-12-11 14:45                               ` Russell King - ARM Linux
2015-12-11 14:45                                 ` Russell King - ARM Linux
2015-12-11 15:08                                 ` Steven Rostedt
2015-12-11 15:08                                   ` Steven Rostedt
2015-12-11 18:10                                 ` Steven Rostedt
2015-12-11 18:10                                   ` Steven Rostedt
2015-12-11 18:33                                   ` Russell King - ARM Linux
2015-12-11 18:33                                     ` Russell King - ARM Linux
2015-12-11 18:51                                     ` Steven Rostedt
2015-12-11 18:51                                       ` Steven Rostedt
2015-12-11 18:58                                       ` Russell King - ARM Linux
2015-12-11 18:58                                         ` Russell King - ARM Linux
2015-12-11 19:28                                         ` Steven Rostedt
2015-12-11 19:28                                           ` Steven Rostedt
2015-11-25 21:51 ` [PATCH v2 2/2] ARM: Replace calls to __aeabi_{u}idiv with udiv/sdiv instructions Stephen Boyd
2015-11-25 21:51   ` Stephen Boyd
2015-11-25 23:09   ` Nicolas Pitre
2015-11-25 23:09     ` Nicolas Pitre
2015-11-26  0:05     ` Russell King - ARM Linux
2015-11-26  0:05       ` Russell King - ARM Linux
2015-11-26  0:07     ` Måns Rullgård
2015-11-26  0:07       ` Måns Rullgård
2015-11-26  0:44       ` Nicolas Pitre
2015-11-26  0:44         ` Nicolas Pitre
2015-11-26  0:50         ` Måns Rullgård
2015-11-26  0:50           ` Måns Rullgård
2015-11-26  0:50           ` Måns Rullgård
2015-11-26  1:28           ` Russell King - ARM Linux
2015-11-26  1:28             ` Russell King - ARM Linux
2015-11-26  1:28             ` Russell King - ARM Linux
2015-11-26  2:19             ` Måns Rullgård
2015-11-26  2:19               ` Måns Rullgård
2015-11-26  2:19               ` Måns Rullgård
2015-11-26  5:32               ` Nicolas Pitre
2015-11-26  5:32                 ` Nicolas Pitre
2015-11-26 12:41                 ` Måns Rullgård
2015-11-26 12:41                   ` Måns Rullgård
2015-11-26 12:41                   ` Måns Rullgård
2015-11-26  0:08   ` Russell King - ARM Linux
2015-11-26  0:08     ` Russell King - ARM Linux
2015-11-26  0:08     ` Russell King - ARM Linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151201171014.GY8644@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mans@mansr.com \
    --cc=mmarek@suse.cz \
    --cc=nico@fluxnic.net \
    --cc=rostedt@goodmis.org \
    --cc=sboyd@codeaurora.org \
    --cc=thomas.petazzoni@free-electrons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.