linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf kcore_copy: Do not check /proc/modules is unchanged
@ 2022-09-14 12:24 Adrian Hunter
  2022-09-14 13:12 ` Daniel Dao
  2022-09-16 18:02 ` Namhyung Kim
  0 siblings, 2 replies; 4+ messages in thread
From: Adrian Hunter @ 2022-09-14 12:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, Daniel Dao, linux-kernel,
	linux-perf-users

/proc/kallsyms and /proc/modules are compared before and after the copy
in order to ensure no changes during the copy. However /proc/modules
also might change due to reference counts changing even though that
does not make any difference. Any modules loaded or unloaded should be
visible in changes to kallsyms, so it is not necessary to check
/proc/modules also anyway.

Remove the comparison checking that /proc/modules is unchanged.

Reported-by: Daniel Dao <dqminh@cloudflare.com>
Fixes: fc1b691d7651 ("perf buildid-cache: Add ability to add kcore to the cache")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/symbol-elf.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 75bec32d4f57..647b7dff8ef3 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -2102,8 +2102,8 @@ static int kcore_copy__compare_file(const char *from_dir, const char *to_dir,
  * unusual.  One significant peculiarity is that the mapping (start -> pgoff)
  * is not the same for the kernel map and the modules map.  That happens because
  * the data is copied adjacently whereas the original kcore has gaps.  Finally,
- * kallsyms and modules files are compared with their copies to check that
- * modules have not been loaded or unloaded while the copies were taking place.
+ * kallsyms file is compared with its copy to check that modules have not been
+ * loaded or unloaded while the copies were taking place.
  *
  * Return: %0 on success, %-1 on failure.
  */
@@ -2166,9 +2166,6 @@ int kcore_copy(const char *from_dir, const char *to_dir)
 			goto out_extract_close;
 	}
 
-	if (kcore_copy__compare_file(from_dir, to_dir, "modules"))
-		goto out_extract_close;
-
 	if (kcore_copy__compare_file(from_dir, to_dir, "kallsyms"))
 		goto out_extract_close;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf kcore_copy: Do not check /proc/modules is unchanged
  2022-09-14 12:24 [PATCH] perf kcore_copy: Do not check /proc/modules is unchanged Adrian Hunter
@ 2022-09-14 13:12 ` Daniel Dao
  2022-09-16 18:02 ` Namhyung Kim
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Dao @ 2022-09-14 13:12 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim, Ian Rogers,
	linux-kernel, linux-perf-users

On Wed, Sep 14, 2022 at 1:24 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> /proc/kallsyms and /proc/modules are compared before and after the copy
> in order to ensure no changes during the copy. However /proc/modules
> also might change due to reference counts changing even though that
> does not make any difference. Any modules loaded or unloaded should be
> visible in changes to kallsyms, so it is not necessary to check
> /proc/modules also anyway.
>
> Remove the comparison checking that /proc/modules is unchanged.
>
> Reported-by: Daniel Dao <dqminh@cloudflare.com>
> Fixes: fc1b691d7651 ("perf buildid-cache: Add ability to add kcore to the cache")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/util/symbol-elf.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index 75bec32d4f57..647b7dff8ef3 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -2102,8 +2102,8 @@ static int kcore_copy__compare_file(const char *from_dir, const char *to_dir,
>   * unusual.  One significant peculiarity is that the mapping (start -> pgoff)
>   * is not the same for the kernel map and the modules map.  That happens because
>   * the data is copied adjacently whereas the original kcore has gaps.  Finally,
> - * kallsyms and modules files are compared with their copies to check that
> - * modules have not been loaded or unloaded while the copies were taking place.
> + * kallsyms file is compared with its copy to check that modules have not been
> + * loaded or unloaded while the copies were taking place.
>   *
>   * Return: %0 on success, %-1 on failure.
>   */
> @@ -2166,9 +2166,6 @@ int kcore_copy(const char *from_dir, const char *to_dir)
>                         goto out_extract_close;
>         }
>
> -       if (kcore_copy__compare_file(from_dir, to_dir, "modules"))
> -               goto out_extract_close;
> -
>         if (kcore_copy__compare_file(from_dir, to_dir, "kallsyms"))
>                 goto out_extract_close;
>
> --
> 2.25.1
>
Thanks Adrian,

Tested-by: Daniel Dao <dqminh@cloudflare.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf kcore_copy: Do not check /proc/modules is unchanged
  2022-09-14 12:24 [PATCH] perf kcore_copy: Do not check /proc/modules is unchanged Adrian Hunter
  2022-09-14 13:12 ` Daniel Dao
@ 2022-09-16 18:02 ` Namhyung Kim
  2022-09-20 20:20   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2022-09-16 18:02 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Ian Rogers, Daniel Dao,
	linux-kernel, linux-perf-users

On Wed, Sep 14, 2022 at 5:24 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> /proc/kallsyms and /proc/modules are compared before and after the copy
> in order to ensure no changes during the copy. However /proc/modules
> also might change due to reference counts changing even though that
> does not make any difference. Any modules loaded or unloaded should be
> visible in changes to kallsyms, so it is not necessary to check
> /proc/modules also anyway.
>
> Remove the comparison checking that /proc/modules is unchanged.
>
> Reported-by: Daniel Dao <dqminh@cloudflare.com>
> Fixes: fc1b691d7651 ("perf buildid-cache: Add ability to add kcore to the cache")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/util/symbol-elf.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index 75bec32d4f57..647b7dff8ef3 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -2102,8 +2102,8 @@ static int kcore_copy__compare_file(const char *from_dir, const char *to_dir,
>   * unusual.  One significant peculiarity is that the mapping (start -> pgoff)
>   * is not the same for the kernel map and the modules map.  That happens because
>   * the data is copied adjacently whereas the original kcore has gaps.  Finally,
> - * kallsyms and modules files are compared with their copies to check that
> - * modules have not been loaded or unloaded while the copies were taking place.
> + * kallsyms file is compared with its copy to check that modules have not been
> + * loaded or unloaded while the copies were taking place.
>   *
>   * Return: %0 on success, %-1 on failure.
>   */
> @@ -2166,9 +2166,6 @@ int kcore_copy(const char *from_dir, const char *to_dir)
>                         goto out_extract_close;
>         }
>
> -       if (kcore_copy__compare_file(from_dir, to_dir, "modules"))
> -               goto out_extract_close;
> -
>         if (kcore_copy__compare_file(from_dir, to_dir, "kallsyms"))
>                 goto out_extract_close;
>
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf kcore_copy: Do not check /proc/modules is unchanged
  2022-09-16 18:02 ` Namhyung Kim
@ 2022-09-20 20:20   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-09-20 20:20 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Adrian Hunter, Jiri Olsa, Ian Rogers, Daniel Dao, linux-kernel,
	linux-perf-users

Em Fri, Sep 16, 2022 at 11:02:25AM -0700, Namhyung Kim escreveu:
> On Wed, Sep 14, 2022 at 5:24 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
> >
> > /proc/kallsyms and /proc/modules are compared before and after the copy
> > in order to ensure no changes during the copy. However /proc/modules
> > also might change due to reference counts changing even though that
> > does not make any difference. Any modules loaded or unloaded should be
> > visible in changes to kallsyms, so it is not necessary to check
> > /proc/modules also anyway.
> >
> > Remove the comparison checking that /proc/modules is unchanged.
> >
> > Reported-by: Daniel Dao <dqminh@cloudflare.com>
> > Fixes: fc1b691d7651 ("perf buildid-cache: Add ability to add kcore to the cache")
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> 
> Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks, applied.

- Arnaldo

 
> Thanks,
> Namhyung
> 
> 
> > ---
> >  tools/perf/util/symbol-elf.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> > index 75bec32d4f57..647b7dff8ef3 100644
> > --- a/tools/perf/util/symbol-elf.c
> > +++ b/tools/perf/util/symbol-elf.c
> > @@ -2102,8 +2102,8 @@ static int kcore_copy__compare_file(const char *from_dir, const char *to_dir,
> >   * unusual.  One significant peculiarity is that the mapping (start -> pgoff)
> >   * is not the same for the kernel map and the modules map.  That happens because
> >   * the data is copied adjacently whereas the original kcore has gaps.  Finally,
> > - * kallsyms and modules files are compared with their copies to check that
> > - * modules have not been loaded or unloaded while the copies were taking place.
> > + * kallsyms file is compared with its copy to check that modules have not been
> > + * loaded or unloaded while the copies were taking place.
> >   *
> >   * Return: %0 on success, %-1 on failure.
> >   */
> > @@ -2166,9 +2166,6 @@ int kcore_copy(const char *from_dir, const char *to_dir)
> >                         goto out_extract_close;
> >         }
> >
> > -       if (kcore_copy__compare_file(from_dir, to_dir, "modules"))
> > -               goto out_extract_close;
> > -
> >         if (kcore_copy__compare_file(from_dir, to_dir, "kallsyms"))
> >                 goto out_extract_close;
> >
> > --
> > 2.25.1
> >

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-20 20:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 12:24 [PATCH] perf kcore_copy: Do not check /proc/modules is unchanged Adrian Hunter
2022-09-14 13:12 ` Daniel Dao
2022-09-16 18:02 ` Namhyung Kim
2022-09-20 20:20   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).