All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pratyush Anand <panand@redhat.com>
To: Will Deacon <will.deacon@arm.com>,
	mark.rutland@arm.com, Peter Zijlstra <peterz@infradead.org>
Cc: linux-arm-kernel@lists.infradead.org,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	huawei.libin@huawei.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 1/4] hw_breakpoint: Add step_needed event attribute
Date: Wed, 26 Jul 2017 11:12:03 +0530	[thread overview]
Message-ID: <70b51184-dbe0-6d0b-c853-be5b556927f1@redhat.com> (raw)
In-Reply-To: <20170725132737.GC28815@arm.com>



On Tuesday 25 July 2017 06:57 PM, Will Deacon wrote:
> On Fri, Jul 07, 2017 at 05:33:57PM +0530, Pratyush Anand wrote:
>> Architecture like ARM64 currently allows to use default hw breakpoint
>> single step handler only to perf. However, some other users like few
>> systemtap tests or kernel test in
>> samples/hw_breakpoint/data_breakpoint.c can also work with default step
>> handler implementation. At the same time, some other like GDB/ptrace may
>> implement their own step handler.
>>
>> Therefore, this patch introduces a new perf_event_attr bit field, so
>> that arch specific code(specially on arm64) can make a decision to
>> enable single stepping.
>>
>> Any architecture which is not using this field will not have any
>> side effect.
>>
>> Signed-off-by: Pratyush Anand <panand@redhat.com>
>> ---
>>   include/linux/hw_breakpoint.h         | 6 ++++++
>>   include/uapi/linux/perf_event.h       | 3 ++-
>>   kernel/events/core.c                  | 2 ++
>>   tools/include/uapi/linux/perf_event.h | 3 ++-
>>   4 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
>> index 0464c85e63fd..6173ae048cbc 100644
>> --- a/include/linux/hw_breakpoint.h
>> +++ b/include/linux/hw_breakpoint.h
>> @@ -38,6 +38,12 @@ static inline int hw_breakpoint_type(struct perf_event *bp)
>>   	return bp->attr.bp_type;
>>   }
>>   
>> +static inline bool
>> +hw_breakpoint_needs_single_step(struct perf_event *bp)
>> +{
>> +	return bp->attr.step_needed;
>> +}
>> +
>>   static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
>>   {
>>   	return bp->attr.bp_len;
>> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
>> index b1c0b187acfe..00935808de0d 100644
>> --- a/include/uapi/linux/perf_event.h
>> +++ b/include/uapi/linux/perf_event.h
>> @@ -345,7 +345,8 @@ struct perf_event_attr {
>>   				context_switch :  1, /* context switch data */
>>   				write_backward :  1, /* Write ring buffer from end to beginning */
>>   				namespaces     :  1, /* include namespaces data */
>> -				__reserved_1   : 35;
>> +				step_needed    :  1, /* Use arch step handler */
>> +				__reserved_1   : 34;
> 
> This needs documenting properly, as I really have no idea how userspace is
> going to use it sensibley, especially as you silently overwrite it in some
> cases below.

I too had thought to put it under include/linux/perf_event.h : struct 
perf_event. But, see hw_break_module_init() which does not have knowledge of 
this structure, and we need to have some way so that none-perf kernel module 
implementation can tell that it needs default arch step handler.

Do you see any alternative?

-- 
Regards
Pratyush

WARNING: multiple messages have this Message-ID (diff)
From: panand@redhat.com (Pratyush Anand)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 1/4] hw_breakpoint: Add step_needed event attribute
Date: Wed, 26 Jul 2017 11:12:03 +0530	[thread overview]
Message-ID: <70b51184-dbe0-6d0b-c853-be5b556927f1@redhat.com> (raw)
In-Reply-To: <20170725132737.GC28815@arm.com>



On Tuesday 25 July 2017 06:57 PM, Will Deacon wrote:
> On Fri, Jul 07, 2017 at 05:33:57PM +0530, Pratyush Anand wrote:
>> Architecture like ARM64 currently allows to use default hw breakpoint
>> single step handler only to perf. However, some other users like few
>> systemtap tests or kernel test in
>> samples/hw_breakpoint/data_breakpoint.c can also work with default step
>> handler implementation. At the same time, some other like GDB/ptrace may
>> implement their own step handler.
>>
>> Therefore, this patch introduces a new perf_event_attr bit field, so
>> that arch specific code(specially on arm64) can make a decision to
>> enable single stepping.
>>
>> Any architecture which is not using this field will not have any
>> side effect.
>>
>> Signed-off-by: Pratyush Anand <panand@redhat.com>
>> ---
>>   include/linux/hw_breakpoint.h         | 6 ++++++
>>   include/uapi/linux/perf_event.h       | 3 ++-
>>   kernel/events/core.c                  | 2 ++
>>   tools/include/uapi/linux/perf_event.h | 3 ++-
>>   4 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
>> index 0464c85e63fd..6173ae048cbc 100644
>> --- a/include/linux/hw_breakpoint.h
>> +++ b/include/linux/hw_breakpoint.h
>> @@ -38,6 +38,12 @@ static inline int hw_breakpoint_type(struct perf_event *bp)
>>   	return bp->attr.bp_type;
>>   }
>>   
>> +static inline bool
>> +hw_breakpoint_needs_single_step(struct perf_event *bp)
>> +{
>> +	return bp->attr.step_needed;
>> +}
>> +
>>   static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
>>   {
>>   	return bp->attr.bp_len;
>> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
>> index b1c0b187acfe..00935808de0d 100644
>> --- a/include/uapi/linux/perf_event.h
>> +++ b/include/uapi/linux/perf_event.h
>> @@ -345,7 +345,8 @@ struct perf_event_attr {
>>   				context_switch :  1, /* context switch data */
>>   				write_backward :  1, /* Write ring buffer from end to beginning */
>>   				namespaces     :  1, /* include namespaces data */
>> -				__reserved_1   : 35;
>> +				step_needed    :  1, /* Use arch step handler */
>> +				__reserved_1   : 34;
> 
> This needs documenting properly, as I really have no idea how userspace is
> going to use it sensibley, especially as you silently overwrite it in some
> cases below.

I too had thought to put it under include/linux/perf_event.h : struct 
perf_event. But, see hw_break_module_init() which does not have knowledge of 
this structure, and we need to have some way so that none-perf kernel module 
implementation can tell that it needs default arch step handler.

Do you see any alternative?

-- 
Regards
Pratyush

  parent reply	other threads:[~2017-07-26  5:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-07 12:03 [PATCH V2 0/4] ARM64: Fix irq generation between breakpoint and step exception Pratyush Anand
2017-07-07 12:03 ` Pratyush Anand
2017-07-07 12:03 ` [PATCH V2 1/4] hw_breakpoint: Add step_needed event attribute Pratyush Anand
2017-07-07 12:03   ` Pratyush Anand
2017-07-25 13:27   ` Will Deacon
2017-07-25 13:27     ` Will Deacon
2017-07-25 14:14     ` Peter Zijlstra
2017-07-25 14:14       ` Peter Zijlstra
2017-07-25 16:04       ` Mark Rutland
2017-07-25 16:04         ` Mark Rutland
2017-07-26  5:42     ` Pratyush Anand [this message]
2017-07-26  5:42       ` Pratyush Anand
2017-07-26  7:49       ` Peter Zijlstra
2017-07-26  7:49         ` Peter Zijlstra
2017-07-07 12:03 ` [PATCH V2 2/4] arm64: use hw_breakpoint_needs_single_step() to decide if step is needed Pratyush Anand
2017-07-07 12:03   ` Pratyush Anand
2017-07-07 12:03 ` [PATCH V2 3/4] hw-breakpoint: sample test: set step_needed bit field Pratyush Anand
2017-07-07 12:03   ` Pratyush Anand
2017-07-07 12:04 ` [PATCH V2 4/4] arm64: disable irq between breakpoint and step exception Pratyush Anand
2017-07-07 12:04   ` Pratyush Anand
2017-07-25 13:25   ` Will Deacon
2017-07-25 13:25     ` Will Deacon
2017-07-26  5:36     ` Pratyush Anand
2017-07-26  5:36       ` Pratyush Anand
2017-07-17  3:21 ` [PATCH V2 0/4] ARM64: Fix irq generation " Pratyush Anand
2017-07-17  3:21   ` Pratyush Anand

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=70b51184-dbe0-6d0b-c853-be5b556927f1@redhat.com \
    --to=panand@redhat.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=huawei.libin@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.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.