linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Cyril Bur <cyrilbur@gmail.com>
To: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
	Michael Neuling <mikey@neuling.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: [PATCH V10 02/28] powerpc, process: Add the function flush_tmregs_to_thread
Date: Wed, 2 Mar 2016 15:56:46 +1100	[thread overview]
Message-ID: <20160302155646.212070ff@camb691> (raw)
In-Reply-To: <56D66C12.9090205@linux.vnet.ibm.com>

On Wed, 02 Mar 2016 09:59:06 +0530
Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:

> On 03/02/2016 05:45 AM, Cyril Bur wrote:
> > On Tue, 16 Feb 2016 14:29:32 +0530
> > Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:
> >   
> >> This patch creates a function flush_tmregs_to_thread which
> >> will then be used by subsequent patches in this series. The
> >> function checks for self tracing ptrace interface attempts
> >> while in the TM context and logs appropriate warning message.
> >>  
> > 
> > Hi Anshuman,
> > 
> > You'll have to bare with me, my ptrace knowledge is non existent so you might
> > have to walk me though some aspects.
> > 
> > I have been playing with FPU/VMX and VSX saving so I thought I'd take a look.  
> 
> Sure.
> 
> 
> >   
> >> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> >> ---
> >>  arch/powerpc/include/asm/switch_to.h |  8 ++++++++
> >>  arch/powerpc/kernel/process.c        | 20 ++++++++++++++++++++
> >>  2 files changed, 28 insertions(+)
> >>
> >> diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h
> >> index 5b268b6..7b297bf 100644
> >> --- a/arch/powerpc/include/asm/switch_to.h
> >> +++ b/arch/powerpc/include/asm/switch_to.h
> >> @@ -70,6 +70,14 @@ static inline void disable_kernel_spe(void)
> >>  }
> >>  #endif
> >>  
> >> +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> >> +extern void flush_tmregs_to_thread(struct task_struct *);
> >> +#else
> >> +static inline void flush_tmregs_to_thread(struct task_struct *t)
> >> +{
> >> +}
> >> +#endif
> >> +
> >>  static inline void clear_task_ebb(struct task_struct *t)
> >>  {
> >>  #ifdef CONFIG_PPC_BOOK3S_64
> >> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> >> index dccc87e..2c4fa7f 100644
> >> --- a/arch/powerpc/kernel/process.c
> >> +++ b/arch/powerpc/kernel/process.c
> >> @@ -918,6 +918,26 @@ static inline void restore_sprs(struct thread_struct *old_thread,
> >>  #endif
> >>  }
> >>    
> > 
> > 
> >   
> >> +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> >> +void flush_tmregs_to_thread(struct task_struct *tsk)
> >> +{
> >> +	/*
> >> +	 * Process self tracing is not yet supported through
> >> +	 * ptrace interface. Ptrace generic code should have
> >> +	 * prevented this from happening in the first place.
> >> +	 * Warn once here with the message, if some how it
> >> +	 * is attempted.
> >> +	 */
> >> +	WARN_ONCE(tsk == current,
> >> +		"Not expecting ptrace on self: TM regs may be incorrect\n");
> >> +
> >> +	/*
> >> +	 * If task is not current, it should have been flushed
> >> +	 * already to it's thread_struct during __switch_to().
> >> +	 */  
> > 
> > I totally agree except this highlights something that I notice in subsequent
> > patches, and existing code. All the *_{get,set}() functions call
> > flush_*_to_thread() when, as per your comment (and my understanding of task
> > switching) there really shouldn't be a need to do that. My only thought is that
> > this could be a relic of uniprocessor days when it would have been necessary but
> > Anton recently stripped that out. Are you able to shed some light here?  
> 
> Its been sometime I had looked into this aspect of the series. I remember
> Michael Neuling and myself discussed about this and settled on a single
> WARN_ON here as nothing else was required to be done in the function. It
> may be possible that all the flush_*_to_thread() functions used else where
> are because of uniprocessor concerns. I dont understand completely our
> context save/restore paths including the lazy ones. I believed that these
> flush_*_to_thread() routines just made sure task struct has the latest
> values of the thread context in case of some complicated save/restore
> paths might not have done the complete save at that point in time.
> 

Well as you note in the comment though, it should be done since we've gone
through __switch_to()...

> If you think that all these flush_*_to_thread() functions used through
> out POWER ptrace need review to see whether they are required or not
> anymore I would suggest we should do it as a separate patch after this
> series and I am willing to work with you on that.

I THINK your patches are correct and we're just performing needless
flush_*_to_thread() calls now in which case its fine and we can review laster,
my concern is that I've been wrong before so having flush_tmregs_to_thread() do
nothing worries me. I wonder if Mr Neuling or Mr Ellerman have anything to say
on the subject...

> 
> > 
> > The reason I ask is that if the flush_*_to_thread() calls ARE actually
> > important then I worry that this function is inadequate...  
> 
> I guess we went through that and finally settled on WARN_ON once but dont
> remember the exact context now. Will look into all previous discussions
> on this and get back.

Thanks,

Cyril
> 

  reply	other threads:[~2016-03-02  4:57 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16  8:59 [PATCH V10 00/28] Add new powerpc specific ELF core notes Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 01/28] elf: Add powerpc specific core note sections Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 02/28] powerpc, process: Add the function flush_tmregs_to_thread Anshuman Khandual
2016-03-02  0:15   ` Cyril Bur
2016-03-02  4:29     ` Anshuman Khandual
2016-03-02  4:56       ` Cyril Bur [this message]
2016-02-16  8:59 ` [PATCH V10 03/28] powerpc, ptrace: Enable in transaction NT_PRFPREG ptrace requests Anshuman Khandual
2016-02-16  9:09   ` Denis Kirjanov
2016-02-16 10:16     ` Michael Ellerman
2016-02-16  8:59 ` [PATCH V10 04/28] powerpc, ptrace: Enable in transaction NT_PPC_VMX " Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 05/28] powerpc, ptrace: Enable in transaction NT_PPC_VSX " Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 06/28] powerpc, ptrace: Adapt gpr32_get, gpr32_set functions for transaction Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 07/28] powerpc, ptrace: Enable support for NT_PPC_CGPR Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 08/28] powerpc, ptrace: Enable support for NT_PPC_CFPR Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 09/28] powerpc, ptrace: Enable support for NT_PPC_CVMX Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 10/28] powerpc, ptrace: Enable support for NT_PPC_CVSX Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 11/28] powerpc, ptrace: Enable support for TM SPR state Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 12/28] powerpc, ptrace: Enable NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 13/28] powerpc, ptrace: Enable support for NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 14/28] powerpc, ptrace: Enable support for EBB registers Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 15/28] selftests, powerpc: Move 'reg.h' file outside of 'ebb' sub directory Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 16/28] selftests, powerpc: Add more SPR numbers, TM & VMX instructions to 'reg.h' Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 17/28] selftests, powerpc: Add ptrace tests for EBB Anshuman Khandual
2016-03-02  0:32   ` Cyril Bur
2016-03-02  8:59     ` Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 18/28] selftests, powerpc: Add ptrace tests for GPR/FPR registers Anshuman Khandual
2016-03-02  0:40   ` Cyril Bur
2016-03-02  9:05     ` Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 19/28] selftests, powerpc: Add ptrace tests for GPR/FPR registers in TM Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 20/28] selftests, powerpc: Add ptrace tests for GPR/FPR registers in suspended TM Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 21/28] selftests, powerpc: Add ptrace tests for TAR, PPR, DSCR registers Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 22/28] selftests, powerpc: Add ptrace tests for TAR, PPR, DSCR in TM Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 23/28] selftests, powerpc: Add ptrace tests for TAR, PPR, DSCR in suspended TM Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 24/28] selftests, powerpc: Add ptrace tests for VSX, VMX registers Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 25/28] selftests, powerpc: Add ptrace tests for VSX, VMX registers in TM Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 26/28] selftests, powerpc: Add ptrace tests for VSX, VMX registers in suspended TM Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 27/28] selftests, powerpc: Add ptrace tests for TM SPR registers Anshuman Khandual
2016-02-16  8:59 ` [PATCH V10 28/28] selftests, powerpc: Add .gitignore file for ptrace executables Anshuman Khandual
2016-04-07  9:23 ` [PATCH V10 00/28] Add new powerpc specific ELF core notes Laurent Dufour
2016-04-07 21:49   ` Michael Ellerman
2016-04-11  6:32     ` Edjunior Barbosa Machado
2016-04-13  5:36       ` Michael Ellerman
2016-04-26 13:23         ` Edjunior Barbosa Machado
2016-04-11  7:40     ` Laurent Dufour
2016-04-13  5:14       ` Michael Ellerman
2016-04-21 16:00         ` Laurent Dufour
2016-05-27  8:07           ` Laurent Dufour
2016-05-30 23:12             ` Michael Ellerman
2016-06-01  8:26               ` Anshuman Khandual
2016-06-02 22:26                 ` Cyril Bur
2016-06-06  8:57                   ` Anshuman Khandual
2016-06-08 11:18                     ` Michael Ellerman
2016-05-06 11:49 ` Michael Ellerman
2016-05-09 12:54   ` Anshuman Khandual

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=20160302155646.212070ff@camb691 \
    --to=cyrilbur@gmail.com \
    --cc=khandual@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    /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 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).