All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
To: Justin Chen <justinpopo6@gmail.com>
Cc: <linux-mips@linux-mips.org>,
	<bcm-kernel-feedback-list@broadcom.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Justin Chen <justin.chen@broadcom.com>
Subject: Re: [RFC] MIPS: Add cacheinfo support
Date: Thu, 8 Dec 2016 17:01:53 -0800	[thread overview]
Message-ID: <584A0281.3040505@imgtec.com> (raw)
In-Reply-To: <CAJx26kW0e-HC0VUTObZ5Or+XjFvE9KmtOToKbFvKYvhE--Vw5A@mail.gmail.com>

On 12/08/2016 04:28 PM, Justin Chen wrote:
> Thanks for the comments Leonid.
>
> We should consider the scope of this patch. The information we are
> trying to expose to userspace is limited to the struct cacheinfo
> located at include/linux/cacheinfo.c (of course this can always be
> expanded). So the question is what information would be useful to
> expose to userspace.
> Some justification for exposing the current information in the
> cacheinfo struct could be: (Pulled from another email chain)
> "Agreed. So far I have got requests from GCC, JIT and graphics guys.
> IIUC they need this to support cache flushing for user applications like
> gcc trampolines and JIT compilers. I am also told that having knowledge
> of cache architecture can help optimal code strategies, though I don't
> have much details on that."
> https://patchwork.kernel.org/patch/5867721/
>
> There may be justification for including the points you mentioned
> above, but I believe that is outside the scope of this patch. The
> cache information exposed in this patch is limited, but I do not
> believe it is useless. The points above can be added, but it will
> require a rework of the base cacheinfo driver. driver/base/cacheinfo.c
>
>
Justin,

CACHE instruction is not available in user space, only SYNCI on MIPS R2+ 
for trampoline.
Any operation with CACHE requires a syscall.

As for SYNCI (trampoline from L1D->L1I) the following information in 
user space is needed:

     1. L1 line size (available via RDHWR $x, $1). It is available now 
directly from CPU, but may be better to supply from kernel because some 
cores has no that.

     2. The flag that L1I is NOT coherent with L1D and SYNCI is needed 
and available

The knowledge about L1/L2 sizes is not needed for regular application... 
well, if application wants to get advantage of cache sizes, well, in 
this case it can be supplied.

But it is unreliable because app may be rescheduled into different kind 
of core which has a different L1 size (in heterogeneous system, BTW). It 
can be fixed by setting affinity, of course (not sure - can it be 
reliably done in BIG/LITTLE approach). But that requires in application 
the knowledge and understanding of system CPU structure... well why we 
can allow all that stuff besides information purpose? It corrupts the 
all efforts and optimization in kernel about performance and powersaving.

Regards,
- Leonid.

WARNING: multiple messages have this Message-ID (diff)
From: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
To: Justin Chen <justinpopo6@gmail.com>
Cc: linux-mips@linux-mips.org, bcm-kernel-feedback-list@broadcom.com,
	Florian Fainelli <f.fainelli@gmail.com>,
	Justin Chen <justin.chen@broadcom.com>
Subject: Re: [RFC] MIPS: Add cacheinfo support
Date: Thu, 8 Dec 2016 17:01:53 -0800	[thread overview]
Message-ID: <584A0281.3040505@imgtec.com> (raw)
Message-ID: <20161209010153.vurH6raERczztGMOYYmpyT-uaGMxvabbKnd0vNkLopw@z> (raw)
In-Reply-To: <CAJx26kW0e-HC0VUTObZ5Or+XjFvE9KmtOToKbFvKYvhE--Vw5A@mail.gmail.com>

On 12/08/2016 04:28 PM, Justin Chen wrote:
> Thanks for the comments Leonid.
>
> We should consider the scope of this patch. The information we are
> trying to expose to userspace is limited to the struct cacheinfo
> located at include/linux/cacheinfo.c (of course this can always be
> expanded). So the question is what information would be useful to
> expose to userspace.
> Some justification for exposing the current information in the
> cacheinfo struct could be: (Pulled from another email chain)
> "Agreed. So far I have got requests from GCC, JIT and graphics guys.
> IIUC they need this to support cache flushing for user applications like
> gcc trampolines and JIT compilers. I am also told that having knowledge
> of cache architecture can help optimal code strategies, though I don't
> have much details on that."
> https://patchwork.kernel.org/patch/5867721/
>
> There may be justification for including the points you mentioned
> above, but I believe that is outside the scope of this patch. The
> cache information exposed in this patch is limited, but I do not
> believe it is useless. The points above can be added, but it will
> require a rework of the base cacheinfo driver. driver/base/cacheinfo.c
>
>
Justin,

CACHE instruction is not available in user space, only SYNCI on MIPS R2+ 
for trampoline.
Any operation with CACHE requires a syscall.

As for SYNCI (trampoline from L1D->L1I) the following information in 
user space is needed:

     1. L1 line size (available via RDHWR $x, $1). It is available now 
directly from CPU, but may be better to supply from kernel because some 
cores has no that.

     2. The flag that L1I is NOT coherent with L1D and SYNCI is needed 
and available

The knowledge about L1/L2 sizes is not needed for regular application... 
well, if application wants to get advantage of cache sizes, well, in 
this case it can be supplied.

But it is unreliable because app may be rescheduled into different kind 
of core which has a different L1 size (in heterogeneous system, BTW). It 
can be fixed by setting affinity, of course (not sure - can it be 
reliably done in BIG/LITTLE approach). But that requires in application 
the knowledge and understanding of system CPU structure... well why we 
can allow all that stuff besides information purpose? It corrupts the 
all efforts and optimization in kernel about performance and powersaving.

Regards,
- Leonid.

  reply	other threads:[~2016-12-09  1:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08  1:16 [RFC] MIPS: Add cacheinfo support justinpopo6
2016-12-08 23:26 ` Leonid Yegoshin
2016-12-08 23:26   ` Leonid Yegoshin
2016-12-09  0:28   ` Justin Chen
2016-12-09  1:01     ` Leonid Yegoshin [this message]
2016-12-09  1:01       ` Leonid Yegoshin
2016-12-12 18:24       ` Florian Fainelli
2016-12-12 20:45         ` Leonid Yegoshin
2016-12-12 20:45           ` Leonid Yegoshin
2016-12-12 21:57           ` Florian Fainelli
2016-12-13  0:19             ` Leonid Yegoshin
2016-12-13  0:19               ` Leonid Yegoshin
2016-12-13 11:09               ` Maciej W. Rozycki
2016-12-13 11:09                 ` Maciej W. Rozycki
2016-12-13 19:18                 ` Leonid Yegoshin
2016-12-13 19:18                   ` Leonid Yegoshin
2016-12-13 20:01                   ` Justin Chen
2016-12-13 20:05                     ` Florian Fainelli
2016-12-13 20:15                       ` Leonid Yegoshin
2016-12-13 20:15                         ` Leonid Yegoshin
2016-12-13 21:53           ` Ralf Baechle
2016-12-13 21:48       ` Ralf Baechle

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=584A0281.3040505@imgtec.com \
    --to=leonid.yegoshin@imgtec.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=f.fainelli@gmail.com \
    --cc=justin.chen@broadcom.com \
    --cc=justinpopo6@gmail.com \
    --cc=linux-mips@linux-mips.org \
    /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.