From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756105AbdKNXBm (ORCPT ); Tue, 14 Nov 2017 18:01:42 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:50952 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753470AbdKNXBd (ORCPT ); Tue, 14 Nov 2017 18:01:33 -0500 X-Google-Smtp-Source: AGs4zMb2tHkxVp8OtcYScdnBhabej3PtPKnpvzBvB768MojYsBM1r+YRm/I1oqwl02DySRVDe3mt/g== Subject: Re: [PATCH 4/4] ARCv2: entry: Reduce perf intr return path To: Peter Zijlstra Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org References: <1510092784-19942-1-git-send-email-vgupta@synopsys.com> <1510092784-19942-5-git-send-email-vgupta@synopsys.com> <20171114102802.GA3165@worktop.lehotels.local> From: Vineet Gupta Message-ID: <8b2c70f0-fc51-fb9b-b799-9b85a3d3403b@gmail.com> Date: Tue, 14 Nov 2017 15:01:26 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171114102802.GA3165@worktop.lehotels.local> Content-Type: multipart/mixed; boundary="------------A6EDCCA24E1B6C74A98DDA9A" Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------A6EDCCA24E1B6C74A98DDA9A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 11/14/2017 02:28 AM, Peter Zijlstra wrote: > On Tue, Nov 07, 2017 at 02:13:04PM -0800, Vineet Gupta wrote: >> In the more likely case of returning to kernel from perf interrupt, do a >> fast path returning w/o bothering about CONFIG_PREEMPT etc > > I think this needs more explaining and certainly also deserves a code > comment. Sure ! It was a quick hack mainly to solicit feedback. > Is the argument something along these lines? > > Assumes the interrupt will never set TIF_NEED_RESCHED; > therefore no preemption is ever required on return from > the interrupt. No. I don't think we can assume that. But I was choosing to ignore it mainly to reduce the overhead of a perf intr in general. A subsequent real interrupt could go thru thru the gyrations of preemption etc. > What do you (on ARC) do about irq_work ? Nothing ATM. At the time of NPS platform upstreaming, Noam had proposed a patch to enable work as part of NO_HZ_FULL support on ARC for NPS. That part of patchseries didn't get merged and then life took over... I'm attaching it here, can be added to ARC I suppose after a bit of deuglification for #ifdef'ery. Although I'm sure it is, can you please explain how irq_work is relevant in the context of this patch. Even w/o the TIF_NEED_RESCHED, the generic intr return could still invoke the irq_work for perf. I remember from my investigations at the time that it was originally needed for perf_event_do_pending() to do stuff in IRQ context. It was later factored out as generic irq_work facility for no_hz and printk ! ------------> From c120294c80d61bcad223c96bd49303357f95afdc Mon Sep 17 00:00:00 2001 From: Noam Camus Date: Sun, 21 Jun 2015 01:41:22 +0300 Subject: [PATCH] ARC: Support arch_irq_work_raise() via self IPIs This will allow the scheduler tick to be restarted. It is used if CONFIG_NO_HZ_FULL. Signed-off-by: Gil Fruchter Signed-off-by: Noam Camus Signed-off-by: Vineet Gupta --- arch/arc/include/asm/Kbuild | 1 - arch/arc/include/asm/irq_work.h | 8 ++++++++ arch/arc/kernel/smp.c | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arc/include/asm/irq_work.h diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index 0b10ef2a4372..f83ec8c04feb 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild @@ -16,7 +16,6 @@ generic-y += ioctl.h generic-y += ioctls.h generic-y += ipcbuf.h generic-y += irq_regs.h -generic-y += irq_work.h generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h diff --git a/arch/arc/include/asm/irq_work.h b/arch/arc/include/asm/irq_work.h new file mode 100644 index 000000000000..40d015199ced --- /dev/null +++ b/arch/arc/include/asm/irq_work.h @@ -0,0 +1,8 @@ +#ifndef _ASM_ARC_IRQ_WORK_H +#define _ASM_ARC_IRQ_WORK_H +static inline bool arch_irq_work_has_interrupt(void) +{ + return true; +} + +#endif /* _ASM_ARC_IRQ_WORK_H */ diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index f2cf58b771b2..c2f49db57265 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -202,6 +203,7 @@ enum ipi_msg_type { IPI_RESCHEDULE = 1, IPI_CALL_FUNC, IPI_CPU_STOP, + IPI_IRQ_WORK, }; /* @@ -276,6 +278,14 @@ void arch_send_call_function_ipi_mask(const struct cpumask *mask) ipi_send_msg(mask, IPI_CALL_FUNC); } +#ifdef CONFIG_IRQ_WORK +void arch_irq_work_raise(void) +{ + if (arch_irq_work_has_interrupt()) + ipi_send_msg_one(smp_processor_id(), IPI_IRQ_WORK); +} +#endif + /* * ipi_cpu_stop - handle IPI from smp_send_stop() */ @@ -301,6 +311,12 @@ static inline int __do_IPI(unsigned long msg) ipi_cpu_stop(); break; +#ifdef CONFIG_IRQ_WORK + case IPI_IRQ_WORK: + irq_work_run(); + break; +#endif + default: rc = 1; } -- 2.7.4 --------------A6EDCCA24E1B6C74A98DDA9A Content-Type: text/x-patch; name="0001-ARC-Support-arch_irq_work_raise-via-self-IPIs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-ARC-Support-arch_irq_work_raise-via-self-IPIs.patch" >>From c120294c80d61bcad223c96bd49303357f95afdc Mon Sep 17 00:00:00 2001 From: Noam Camus Date: Sun, 21 Jun 2015 01:41:22 +0300 Subject: [PATCH] ARC: Support arch_irq_work_raise() via self IPIs This will allow the scheduler tick to be restarted. It is used if CONFIG_NO_HZ_FULL. Signed-off-by: Gil Fruchter Signed-off-by: Noam Camus Signed-off-by: Vineet Gupta --- arch/arc/include/asm/Kbuild | 1 - arch/arc/include/asm/irq_work.h | 8 ++++++++ arch/arc/kernel/smp.c | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arc/include/asm/irq_work.h diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index 0b10ef2a4372..f83ec8c04feb 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild @@ -16,7 +16,6 @@ generic-y += ioctl.h generic-y += ioctls.h generic-y += ipcbuf.h generic-y += irq_regs.h -generic-y += irq_work.h generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h diff --git a/arch/arc/include/asm/irq_work.h b/arch/arc/include/asm/irq_work.h new file mode 100644 index 000000000000..40d015199ced --- /dev/null +++ b/arch/arc/include/asm/irq_work.h @@ -0,0 +1,8 @@ +#ifndef _ASM_ARC_IRQ_WORK_H +#define _ASM_ARC_IRQ_WORK_H +static inline bool arch_irq_work_has_interrupt(void) +{ + return true; +} + +#endif /* _ASM_ARC_IRQ_WORK_H */ diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index f2cf58b771b2..c2f49db57265 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -202,6 +203,7 @@ enum ipi_msg_type { IPI_RESCHEDULE = 1, IPI_CALL_FUNC, IPI_CPU_STOP, + IPI_IRQ_WORK, }; /* @@ -276,6 +278,14 @@ void arch_send_call_function_ipi_mask(const struct cpumask *mask) ipi_send_msg(mask, IPI_CALL_FUNC); } +#ifdef CONFIG_IRQ_WORK +void arch_irq_work_raise(void) +{ + if (arch_irq_work_has_interrupt()) + ipi_send_msg_one(smp_processor_id(), IPI_IRQ_WORK); +} +#endif + /* * ipi_cpu_stop - handle IPI from smp_send_stop() */ @@ -301,6 +311,12 @@ static inline int __do_IPI(unsigned long msg) ipi_cpu_stop(); break; +#ifdef CONFIG_IRQ_WORK + case IPI_IRQ_WORK: + irq_work_run(); + break; +#endif + default: rc = 1; } -- 2.7.4 --------------A6EDCCA24E1B6C74A98DDA9A--