<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi Christophe,<br>
      <br>
                  Thankyou for reviewing the patch.<br>
    </p>
    <div class="moz-cite-prefix">On 12/5/19 11:28 AM, Christophe Leroy
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:0e5028bc-b8bc-e2f5-855f-9df5bfb58dad@c-s.fr">
      <br>
      <br>
      Le 05/12/2019 à 06:25, Kajol Jain a écrit :
      <br>
      <blockquote type="cite">Many of the performance moniroting unit
        (PMU) SPRs are
        <br>
        exposed in the sysfs. "perf" API is the primary interface to
        program
        <br>
        PMU and collect counter data in the system. So expose these
        <br>
        PMU SPRs in the absence of CONFIG_PERF_EVENTS.
        <br>
        <br>
        Patch adds a new CONFIG option 'CONFIG_PMU_SYSFS'. The new
        config
        <br>
        option used in kernel/sysfs.c for PMU SPRs sysfs file creation
        and
        <br>
        this new option is enabled only if 'CONFIG_PERF_EVENTS' option
        is
        <br>
        disabled.
        <br>
      </blockquote>
      <br>
      Not sure this new unselectable option is worth it. See below.
      <br>
      By the way I also find the subject misleading, as you may believe
      when reading it that there is something to select.
      <br>
    </blockquote>
    <p><br>
    </p>
    <p>Ok I wiil change the subject.</p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:0e5028bc-b8bc-e2f5-855f-9df5bfb58dad@c-s.fr">
      <br>
      <blockquote type="cite">
        <br>
        Tested this patch with enable/disable CONFIG_PERF_EVENTS option
        <br>
        in powernv and pseries machines.
        <br>
        Also did compilation testing for different architecture include:
        <br>
        x86, mips, mips64, alpha, arm. And with book3s_32.config option.
        <br>
      </blockquote>
      <br>
      How do you use book3s_32.config exactly ? That's a portion of
      config, not a config by itself. You should use pmac32_defconfig I
      guess.
      <br>
    </blockquote>
    <p><br>
    </p>
    <p>Yes you are right, its not a config option. Actually I was
      playing around with '<span style="color: rgb(29, 28, 29);
        font-family: Slack-Lato, appleLogo, sans-serif; font-size: 15px;
        font-style: normal; font-variant-ligatures: common-ligatures;
        font-variant-caps: normal; font-weight: 400; letter-spacing:
        normal; orphans: 2; text-align: left; text-indent: 0px;
        text-transform: none; white-space: normal; widows: 2;
        word-spacing: 0px; -webkit-text-stroke-width: 0px;
        background-color: rgb(248, 248, 248); text-decoration-style:
        initial; text-decoration-color: initial; display: inline
        !important; float: none;">CONFIG_PPC_BOOK3S' option in .config
        file. As you suggested,</span></p>
    <p><span style="color: rgb(29, 28, 29); font-family: Slack-Lato,
        appleLogo, sans-serif; font-size: 15px; font-style: normal;
        font-variant-ligatures: common-ligatures; font-variant-caps:
        normal; font-weight: 400; letter-spacing: normal; orphans: 2;
        text-align: left; text-indent: 0px; text-transform: none;
        white-space: normal; widows: 2; word-spacing: 0px;
        -webkit-text-stroke-width: 0px; background-color: rgb(248, 248,
        248); text-decoration-style: initial; text-decoration-color:
        initial; display: inline !important; float: none;">I will try to
        build with '</span><span style="color: rgb(29, 28, 29);
        font-family: Slack-Lato, appleLogo, sans-serif; font-size: 15px;
        font-style: normal; font-variant-ligatures: common-ligatures;
        font-variant-caps: normal; font-weight: 400; letter-spacing:
        normal; orphans: 2; text-align: left; text-indent: 0px;
        text-transform: none; white-space: normal; widows: 2;
        word-spacing: 0px; -webkit-text-stroke-width: 0px;
        background-color: rgb(248, 248, 248); text-decoration-style:
        initial; text-decoration-color: initial; display: inline
        !important; float: none;">pmac32_defconfig' option.</span></p>
    <p><span style="color: rgb(29, 28, 29); font-family: Slack-Lato,
        appleLogo, sans-serif; font-size: 15px; font-style: normal;
        font-variant-ligatures: common-ligatures; font-variant-caps:
        normal; font-weight: 400; letter-spacing: normal; orphans: 2;
        text-align: left; text-indent: 0px; text-transform: none;
        white-space: normal; widows: 2; word-spacing: 0px;
        -webkit-text-stroke-width: 0px; background-color: rgb(248, 248,
        248); text-decoration-style: initial; text-decoration-color:
        initial; display: inline !important; float: none;"><br>
      </span></p>
    <blockquote type="cite"
      cite="mid:0e5028bc-b8bc-e2f5-855f-9df5bfb58dad@c-s.fr">
      <br>
      <blockquote type="cite">
        <br>
        Signed-off-by: Kajol Jain <a class="moz-txt-link-rfc2396E" href="mailto:kjain@linux.ibm.com"><kjain@linux.ibm.com></a>
        <br>
        <br>
        Reviewed-by: Madhavan Srinivasan
        <a class="moz-txt-link-rfc2396E" href="mailto:maddy@linux.vnet.ibm.com"><maddy@linux.vnet.ibm.com></a>
        <br>
        Tested-by: Nageswara R Sastry <a class="moz-txt-link-rfc2396E" href="mailto:nasastry@in.ibm.com"><nasastry@in.ibm.com></a>
        <br>
        <br>
        Tested using the following different scenarios:
        <br>
        1. CONFIG_PERF_EVENT - enabled, CONFIG_PMU_SYSFS - disabled,
        <br>
        RESULT: not seen any sysfs files(mmrc*, pmc*) from
        /sys/bus/cpu/devices/cpu?/
        <br>
        2. CONFIG_PERF_EVENT - disabled, CONFIG_PMU_SYSFS - enabled,
        <br>
        RESULT: seen any sysfs files(mmrc*, pmc*) from
        /sys/bus/cpu/devices/cpu?/
        <br>
        3. CONFIG_PERF_EVENT -disabled, CONFIG_PMU_SYSFS - disabled,
        <br>
        RESULT: not possible, any one of the config options need to be
        enabled.
        <br>
        4. CONFIG_PERF_EVENT -enabled, CONFIG_PMU_SYSFS - enabled,
        <br>
        RESULT: not possible, any one of the config options need to be
        enabled.
        <br>
        ---
        <br>
          arch/powerpc/kernel/sysfs.c            | 21
        +++++++++++++++++++++
        <br>
          arch/powerpc/platforms/Kconfig.cputype |  8 ++++++++
        <br>
          2 files changed, 29 insertions(+)
        <br>
        <br>
        ---
        <br>
        Changelog:
        <br>
        Resend v2
        <br>
            Added 'Reviewed-by' and 'Tested-by' tag along with test
        scenarios.    <br>
        <br>
        v1 -> v2
        <br>
        - Added new config option 'PMU_SYSFS' for PMU SPR's creation
        <br>
           rather than using PERF_EVENTS config option directly and make
        <br>
           sure SPR's file creation only if 'CONFIG_PERF_EVENTS'
        disabled.
        <br>
        ---
        <br>
        diff --git a/arch/powerpc/kernel/sysfs.c
        b/arch/powerpc/kernel/sysfs.c
        <br>
        index 80a676da11cb..b7c01f1ef236 100644
        <br>
        --- a/arch/powerpc/kernel/sysfs.c
        <br>
        +++ b/arch/powerpc/kernel/sysfs.c
        <br>
        @@ -457,16 +457,21 @@ static ssize_t __used \
        <br>
            #if defined(CONFIG_PPC64)
        <br>
          #define HAS_PPC_PMC_CLASSIC    1
        <br>
        +#ifdef CONFIG_PMU_SYSFS
        <br>
          #define HAS_PPC_PMC_IBM        1
        <br>
        +#endif
        <br>
          #define HAS_PPC_PMC_PA6T    1
        <br>
          #elif defined(CONFIG_PPC_BOOK3S_32)
        <br>
          #define HAS_PPC_PMC_CLASSIC    1
        <br>
        +#ifdef CONFIG_PMU_SYSFS
        <br>
          #define HAS_PPC_PMC_IBM        1
        <br>
          #define HAS_PPC_PMC_G4        1
        <br>
          #endif
        <br>
        +#endif
        <br>
              #ifdef HAS_PPC_PMC_CLASSIC
        <br>
        +#ifdef CONFIG_PMU_SYSFS
        <br>
      </blockquote>
      <br>
      You don't need this big forest of #ifdefs (this one and all the
      ones after). All the objets you are protecting with this are
      indeed static. So the only thing you have to do is to register
      them only when relevant, and GCC will get rid of the objects by
      itself when the config option is not enabled. See below.
      <br>
      <br>
      And the advantage of doing that way is that you don't need to
      build it with both options to check the build. That's recommended
      by kernel codying style (Refer
<a class="moz-txt-link-freetext" href="https://www.kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation">https://www.kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation</a>)<br>
      <br>
      [...]
      <br>
      <br>
      <blockquote type="cite">@@ -787,8 +804,10 @@ static int
        register_cpu_online(unsigned int cpu)
        <br>
                      device_create_file(s, &pmc_attrs[i]);
        <br>
            #ifdef CONFIG_PPC64
        <br>
        +#ifdef CONFIG_PMU_SYSFS
        <br>
      </blockquote>
      <br>
      Don't use #ifdef here, just do instead:
      <br>
      <br>
      if (IS_ENABLED(CONFIG_PMU_SYSFS) &&
      cpu_has_feature(CPU_FTR_MMCRA))
      <br>
    </blockquote>
    <p><br>
    </p>
    <p>Thanks for the suggestion I will use IS_ENABLED here.</p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:0e5028bc-b8bc-e2f5-855f-9df5bfb58dad@c-s.fr">
      <br>
      <blockquote type="cite">      if (cpu_has_feature(CPU_FTR_MMCRA))
        <br>
                  device_create_file(s, &dev_attr_mmcra);
        <br>
        +#endif /* CONFIG_PMU_SYSFS */
        <br>
                if (cpu_has_feature(CPU_FTR_PURR)) {
        <br>
                  if (!firmware_has_feature(FW_FEATURE_LPAR))
        <br>
        @@ -876,8 +895,10 @@ static int unregister_cpu_online(unsigned
        int cpu)
        <br>
                      device_remove_file(s, &pmc_attrs[i]);
        <br>
            #ifdef CONFIG_PPC64
        <br>
        +#ifdef CONFIG_PMU_SYSFS
        <br>
      </blockquote>
      <br>
      Same, use IS_ENABLED() here as well.
      <br>
      <br>
      <blockquote type="cite">      if (cpu_has_feature(CPU_FTR_MMCRA))
        <br>
                  device_remove_file(s, &dev_attr_mmcra);
        <br>
        +#endif /* CONFIG_PMU_SYSFS */
        <br>
                if (cpu_has_feature(CPU_FTR_PURR))
        <br>
                  device_remove_file(s, &dev_attr_purr);
        <br>
        diff --git a/arch/powerpc/platforms/Kconfig.cputype
        b/arch/powerpc/platforms/Kconfig.cputype
        <br>
        index 12543e53fa96..f3ad579c559f 100644
        <br>
        --- a/arch/powerpc/platforms/Kconfig.cputype
        <br>
        +++ b/arch/powerpc/platforms/Kconfig.cputype
        <br>
        @@ -417,6 +417,14 @@ config PPC_MM_SLICES
        <br>
          config PPC_HAVE_PMU_SUPPORT
        <br>
                 bool
        <br>
          +config PMU_SYSFS
        <br>
        +    bool
        <br>
        +    default y if !PERF_EVENTS
        <br>
        +    help
        <br>
        +      This option enables PMU SPR sysfs file creation. Since
        PMU SPRs are
        <br>
        +      intended to be used via "perf" interface, config option
        is enabled
        <br>
        +      only when CONFIG_PERF_EVENTS is disabled.
        <br>
        +
        <br>
      </blockquote>
      <br>
      Not sure you need this at all. Once you have changed to just using
      IS_ENABLED() in the two places above, I think it is acceptable to
      use !IS_ENABLED(CONFIG_PERF_EVENTS) instead.
      <br>
    </blockquote>
    <br>
    <p>Actually with v1 of the patch, I tried with PERF_EVENT option,
      but it was getting bit messy to recreate the current arrangement
      in the file. So took a new config option path.</p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:0e5028bc-b8bc-e2f5-855f-9df5bfb58dad@c-s.fr">
      <br>
      <blockquote type="cite">  config PPC_PERF_CTRS
        <br>
                 def_bool y
        <br>
                 depends on PERF_EVENTS && PPC_HAVE_PMU_SUPPORT
        <br>
        <br>
      </blockquote>
      <br>
      <br>
      Christophe
      <br>
    </blockquote>
    <p><br>
    </p>
    <p>Thanks,</p>
    <p>Kajol Jain<br>
    </p>
  </body>
</html>