From patchwork Mon May 13 10:29:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 164018 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1141320ili; Mon, 13 May 2019 03:30:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyt34fG12Dj21OoeKFMILJrUr/3OHZYGsjg44ZLcXth6MwleJHwtoxDw/viywdcCdLhWxw6 X-Received: by 2002:a63:4820:: with SMTP id v32mr29599314pga.89.1557743416899; Mon, 13 May 2019 03:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557743416; cv=none; d=google.com; s=arc-20160816; b=ttpNVpKYA12W+ftpv8d4MomZdO4ziQPZN36Jun/aS4PewiR1/O5vuTc/su0bcc5sGu syq8GZ1ynECK49x9UlcS+zyp4f9CXDWAapvUVXT6iZnWKd1+qbq6eW0Q61ErrDotm2qS WqKafzKaV696FPi7ZM1S5YcX5I8etQxD23q18V43IqN4MjgBpp6xAevQHnaElj+Ir5GG /iBS4fmylnNYPJWh7LEj0nVMYpQWwXH+NSXP0hvm/8hZQvMuNa110vymZ/69TOGzUn8K UVslt2qyDwul6MjXwqMb+CMrFFsKbUXPmd8qECKKz/su0+U887xaiWK517vu5DsRAO7X zqqQ== 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; bh=lvZ+JFSB5ojt72GfMWAJ6EobprUjj+jvH2Pe8i8Nlqo=; b=zRyCcd00gp1YDQuQa/LOZGz36D/KphA/uBGc0IefzaMMgGFAk/uyWsPj5M/81nmvwb DJ0dQ4jWaWauNYKOKKviTjjVldEFRM4aF28aTpv2cXkWvQnn3TOCN9zA5Y4vx8NDbx+E /zWzEjHcDIS56leySS00l55h9CBH8ZcvWNim9ftHEfl61FyMdpK7g44wfx/k8mHzs4JL NBkmzzBXQ0VYD4STcuuaO9/wdPDyJHK+d33wQaRgY9vCpnVgov0aiaEfu9kXEad8RmA5 mBlcOOrzWWbCCkpnnAUq1ENElOEgRlvGtkt8wfQ1kC2XZustRd3IvF1XY6nxPTWONTDo X39g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dSHCuoqo; 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 n8si14997508plk.108.2019.05.13.03.30.16; Mon, 13 May 2019 03:30:16 -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.s=google header.b=dSHCuoqo; 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 S1728650AbfEMKaP (ORCPT + 30 others); Mon, 13 May 2019 06:30:15 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52274 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728613AbfEMKaN (ORCPT ); Mon, 13 May 2019 06:30:13 -0400 Received: by mail-wm1-f65.google.com with SMTP id y3so3881738wmm.2 for ; Mon, 13 May 2019 03:30:12 -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=lvZ+JFSB5ojt72GfMWAJ6EobprUjj+jvH2Pe8i8Nlqo=; b=dSHCuoqojnoQnhQPXQz7BOVR+dK7em4UWq9W9rNbeZ12DzLkg6+CSMkUVF3RJoH8J9 3vwrdsnfCIYmRc69SgZPhD1rK9ulkby2MgOFR/87kjRSScR3JLGSzjEfJ0uPDXpVN0q+ Bh6wnWmJfVs2UvMmrwleiJq8wtf8GMI3Jr55Gea3Ooec/6xHIj7t3WENxc0iopWgbhz1 a/dgI5WH/UCZej5n3L9XHCoseNge88nTv9znxrHgM7ZFwJAMHYqeUOmyE7UGhCE/I7zI 8P1EqmHWjKo3UBzbTpjmKGK5uB8U6nqufkFVdg8QY1gvQcjYk9OqOtOadY3pFUvwNC7r Iuxw== 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=lvZ+JFSB5ojt72GfMWAJ6EobprUjj+jvH2Pe8i8Nlqo=; b=ER6m2I3ThIzqWFkdGokY60B9JsyXEfE/ZPrpaB8lO4SB0urCPDPqYXWMTt0q3q7JSJ u7Q983f6nuMXcKlDTHTXKnLbg9XfGOunxBHDM8BMcUQUnVauUI9BBTDAKM9APGJh88NF lBtK0HKIA1JCdC4MuIfEZv8vONCB35tlic376Ych7Sp4DRPW6A6mfRYOpaUnCTRuiT34 uqwv+iE7m9We1zRwdUbom9bbljXZDoNhqjahfWLLc27W5GOB2w3podZJApGptwlZ6N0l M6j13BKEIi0HHyyJ9vTPsBDag+AUqNnHNUM/uN3rSJJhBKG0pnDSvWvRWZ4eNxyMITey kobw== X-Gm-Message-State: APjAAAWCyZw95Y/hMeztXwMMa5p6VCMdzpI5vBc9GOdwtjrSnONO7YZo tKccAQjwrKobvC90Sr4RGhWYzCYpT60= X-Received: by 2002:a1c:b782:: with SMTP id h124mr15844451wmf.5.1557743411330; Mon, 13 May 2019 03:30:11 -0700 (PDT) Received: from clegane.local (205.29.129.77.rev.sfr.net. [77.129.29.205]) by smtp.gmail.com with ESMTPSA id v192sm13645238wme.24.2019.05.13.03.30.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 03:30:10 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 6/9] genirq/timings: Encapsulate storing function Date: Mon, 13 May 2019 12:29:50 +0200 Message-Id: <20190513102953.16424-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190513102953.16424-1-daniel.lezcano@linaro.org> References: <20190513102953.16424-1-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For the next patches providing the selftest, we want to insert interval values directly in the buffer in order to check the correctness of the code. Encapsulate the code doing that in a always inline function in order to reuse it in the test code. No functional changes. Signed-off-by: Daniel Lezcano --- kernel/irq/timings.c | 53 ++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/kernel/irq/timings.c b/kernel/irq/timings.c index 8928601b4b42..02689e6168c4 100644 --- a/kernel/irq/timings.c +++ b/kernel/irq/timings.c @@ -431,11 +431,43 @@ static u64 __irq_timings_next_event(struct irqt_stat *irqs, int irq, u64 now) return irqs->last_ts + irqs->ema_time[index]; } +static __always_inline int irq_timings_interval_index(u64 interval) +{ + /* + * The PREDICTION_FACTOR increase the interval size for the + * array of exponential average. + */ + u64 interval_us = (interval >> 10) / PREDICTION_FACTOR; + + return likely(interval_us) ? ilog2(interval_us) : 0; +} + +static __always_inline void __irq_timings_store(int irq, struct irqt_stat *irqs, + u64 interval) +{ + int index; + + /* + * Get the index in the ema table for this interrupt. + */ + index = irq_timings_interval_index(interval); + + /* + * Store the index as an element of the pattern in another + * circular array. + */ + irqs->circ_timings[irqs->count & IRQ_TIMINGS_MASK] = index; + + irqs->ema_time[index] = irq_timings_ema_new(interval, + irqs->ema_time[index]); + + irqs->count++; +} + static inline void irq_timings_store(int irq, struct irqt_stat *irqs, u64 ts) { u64 old_ts = irqs->last_ts; u64 interval; - int index; /* * The timestamps are absolute time values, we need to compute @@ -466,24 +498,7 @@ static inline void irq_timings_store(int irq, struct irqt_stat *irqs, u64 ts) return; } - /* - * Get the index in the ema table for this interrupt. The - * PREDICTION_FACTOR increase the interval size for the array - * of exponential average. - */ - index = likely(interval) ? - ilog2((interval >> 10) / PREDICTION_FACTOR) : 0; - - /* - * Store the index as an element of the pattern in another - * circular array. - */ - irqs->circ_timings[irqs->count & IRQ_TIMINGS_MASK] = index; - - irqs->ema_time[index] = irq_timings_ema_new(interval, - irqs->ema_time[index]); - - irqs->count++; + __irq_timings_store(irq, irqs, interval); } /**