From patchwork Tue Jun 20 21:28:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 106029 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1607792qgd; Tue, 20 Jun 2017 14:30:23 -0700 (PDT) X-Received: by 10.98.63.138 with SMTP id z10mr3856724pfj.203.1497994223793; Tue, 20 Jun 2017 14:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497994223; cv=none; d=google.com; s=arc-20160816; b=glih3uQlKsj+04CUzHH+rdc8oCAB/9FtasbC6I/7S8HzCktAqHNK2g/jrhvrqL5cPj VIB+1Lc9MdgF72ydXCwQ2p2feY6dcqUuqCKTWcCXMi/47E7ZtaG+x8ZH9ziXqdf1OX/n y804WYd0rY36Mf6IphW81//9JhbvQ3eQOE6JuJiGM4EG1owuCl42UlCHZZf86IdKdsIo vQXE8voQXgiIf4IXlN/VMGbd6fbscD1wLr9gpM1xrz7jHG5x65aJB83Y2qVDCNhaUPem COk3oYuvILcH8a3jWp40O0l27vtzzd9P4EvgDCl5AqYjk9gE5R1JKVDpRw/XLfu4x+nJ qg7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=iIMOoa2LzPYwv1IOW4YPVJ8A7ooVUYcH8Q+Cnr8W3NM=; b=oYWR07pRGJzhy9KV3Ie14EkMlBa4qJHp7GHa7j25a7dGPK6map/0pdoU4zio0wjOYa HLzkt1HWnx8Mvjf/7Ky8EXOlxM1LrmSZBpscnWFI9ANCRV34c6Anr3tIRxgFJXm8bAiT OE5aJgAlTc2v8pEbdoRzzxqrOwabY3T8r4+GvFkuHP5LAuUR3kz2u7ffxiwPIpcuExff jmEn5/6D3inQHyHFFCrwYqt7UgiI9QyX2l5ORCbKZ2bCvE9fEgp2PsHZJoYRyI7nrpZE yP2qQnZHPiEc0kKzvVyGlxb+ilYR0g/KyiNFZhOHR3LBIEclrdhs2f/hiSzPxKCpCPcD nwpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=WfgU66nK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si12395690plk.261.2017.06.20.14.30.23; Tue, 20 Jun 2017 14:30:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=WfgU66nK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619AbdFTVaV (ORCPT + 25 others); Tue, 20 Jun 2017 17:30:21 -0400 Received: from mail-wr0-f173.google.com ([209.85.128.173]:35216 "EHLO mail-wr0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751090AbdFTVaT (ORCPT ); Tue, 20 Jun 2017 17:30:19 -0400 Received: by mail-wr0-f173.google.com with SMTP id y25so69187102wrd.2 for ; Tue, 20 Jun 2017 14:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iIMOoa2LzPYwv1IOW4YPVJ8A7ooVUYcH8Q+Cnr8W3NM=; b=WfgU66nKfSSGwEl8K7jEUKwo9M2SE/O+oxiwEaThHddmO6t76D/dgKrBlBEjdmRu1m 4GKJ94XbEB+clMGba1zWuygguXTKjnnYLEL09x6onedMFe/H4i82WbSh8L/MaP7STHvf LBDjtcs+1tvBvN4vuHk8tmqMtabkjQ2mpu6YQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iIMOoa2LzPYwv1IOW4YPVJ8A7ooVUYcH8Q+Cnr8W3NM=; b=NwrDaP2jDOWaYrxpSNFXY13zbeFZoW32XOCgvo+wNy8aiR29n+bdpiZdpuJ5toFvNU P2WYhArFBQu8Hq+/ts2ItEVkoj2DheyJERkl7OxnIrxUvwdgloBZslDYyqBxTBIROs3d taITASZKRQB9U/ijsoWSZA/Hv2J7r8k3iD9LS6uE0zo6hrtUKeEX0Xxl2/j86gkp+SIz mZWAclOfLqaAsiYenUVSTYmPMJaYhKYclGijBX4yH4yBk6Ck3cHSw9NkiGlB+LQKFZrx lsfg4NInMiD+HV+SrACecxtVOwyon67ukHjfoql6jNWdoBpOV31z1FtzCAoqVud+5ZwS gouA== X-Gm-Message-State: AKS2vOz3VNCs1ejlq6R5T/rcZawyJLtlcYLxIz41cmsf7GKyFgmcV4mw cgqaIJ3GwkkLMDhfXhwF9g== X-Received: by 10.28.210.194 with SMTP id j185mr4246031wmg.36.1497994218296; Tue, 20 Jun 2017 14:30:18 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:ccbe:9633:e651:d298]) by smtp.gmail.com with ESMTPSA id o7sm13044234wmd.0.2017.06.20.14.30.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 14:30:17 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Mark Rutland , Jens Axboe , Hannes Reinecke , Bjorn Helgaas Subject: [PATCH 1/3] irq: Allow to pass the IRQF_TIMER flag with percpu irq request Date: Tue, 20 Jun 2017 23:28:55 +0200 Message-Id: <1497994139-19816-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170620212657.GB1812@mai> References: <20170620212657.GB1812@mai> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the next changes, we track when the interrupts occur in order to statistically compute when is supposed to happen the next interrupt. In all the interruptions, it does not make sense to store the timer interrupt occurences and try to predict the next interrupt as we know the expiration time. The request_irq() has a irq flags parameter and the timer drivers use it to pass the IRQF_TIMER flag, letting us know the interrupt is coming from a timer. Based on this flag, we can discard these interrupts when tracking them. But, the API request_percpu_irq does not allow to pass a flag, hence specifying if the interrupt type is a timer. Add a function __request_percpu_irq() where we can specify the flags. The request_percpu_irq() function is changed to be a wrapper to __request_percpu_irq() passing a zero flag parameter. For now, in order to prevent a misusage of this parameter, only the IRQF_TIMER flag (or zero) is a valid parameter to be passed to the __request_percpu_irq() function. Signed-off-by: Daniel Lezcano Cc: Mark Rutland --- Changelog: V11: - Drop the changes in the timer drivers and rename the function request_percpu_irq_flags to __request_percpu_irq. V10: - Drop the change for arch arm virtual timer https://lkml.org/lkml/2017/4/25/184 V9: - Clarified the patch description - Fixed EXPORT_SYMBOL_GPL(request_percpu_irq_flags) Signed-off-by: Daniel Lezcano --- include/linux/interrupt.h | 11 ++++++++++- kernel/irq/manage.c | 15 ++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) -- 2.7.4 Acked-by: Mark Rutland diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index a6fba48..d4ae50e 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -152,8 +152,17 @@ request_any_context_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev_id); extern int __must_check +__request_percpu_irq(unsigned int irq, irq_handler_t handler, + unsigned long flags, const char *devname, + void __percpu *percpu_dev_id); + +static inline int __must_check request_percpu_irq(unsigned int irq, irq_handler_t handler, - const char *devname, void __percpu *percpu_dev_id); + const char *devname, void __percpu *percpu_dev_id) +{ + return __request_percpu_irq(irq, handler, 0, + devname, percpu_dev_id); +} extern const void *free_irq(unsigned int, void *); extern void free_percpu_irq(unsigned int, void __percpu *); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 4c34696..5424cfb 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1974,9 +1974,10 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act) } /** - * request_percpu_irq - allocate a percpu interrupt line + * __request_percpu_irq - allocate a percpu interrupt line * @irq: Interrupt line to allocate * @handler: Function to be called when the IRQ occurs. + * @flags: Interrupt type flags (IRQF_TIMER only) * @devname: An ascii name for the claiming device * @dev_id: A percpu cookie passed back to the handler function * @@ -1989,8 +1990,9 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act) * the handler gets called with the interrupted CPU's instance of * that variable. */ -int request_percpu_irq(unsigned int irq, irq_handler_t handler, - const char *devname, void __percpu *dev_id) +int __request_percpu_irq(unsigned int irq, irq_handler_t handler, + unsigned long flags, const char *devname, + void __percpu *dev_id) { struct irqaction *action; struct irq_desc *desc; @@ -2004,12 +2006,15 @@ int request_percpu_irq(unsigned int irq, irq_handler_t handler, !irq_settings_is_per_cpu_devid(desc)) return -EINVAL; + if (flags && flags != IRQF_TIMER) + return -EINVAL; + action = kzalloc(sizeof(struct irqaction), GFP_KERNEL); if (!action) return -ENOMEM; action->handler = handler; - action->flags = IRQF_PERCPU | IRQF_NO_SUSPEND; + action->flags = flags | IRQF_PERCPU | IRQF_NO_SUSPEND; action->name = devname; action->percpu_dev_id = dev_id; @@ -2030,7 +2035,7 @@ int request_percpu_irq(unsigned int irq, irq_handler_t handler, return retval; } -EXPORT_SYMBOL_GPL(request_percpu_irq); +EXPORT_SYMBOL_GPL(__request_percpu_irq); /** * irq_get_irqchip_state - returns the irqchip state of a interrupt.