From patchwork Mon May 27 20:55:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 165228 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7616626ili; Mon, 27 May 2019 13:55:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfgUg2ROo23+xKjl2kMEYfVDpZN4B+GZTfZy7aoHXF/nxY1TV62R49H6LVK0/cn2LXHC60 X-Received: by 2002:a17:90a:1b0b:: with SMTP id q11mr869168pjq.80.1558990558199; Mon, 27 May 2019 13:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558990558; cv=none; d=google.com; s=arc-20160816; b=Z2r5qRPPWynGodggR5ZMdBBQn469q/tYgHkWqnO5hbXSdtRb9hPDnpQWsnfjZ4YOWb H6KFUDc9+WY+JLQc6eovPxj/A1cOIT7mVl9VFquYAvJHfbjo7tOaqUXPpx10VRfitMC0 Lv0JDFp3DlfGtCpe+2Lmv0Ck1EamqmHTSTyalGKejpKhplxB2UhokufoLZ5DfclFivKM 7MISVyq8iehMLvq7TsRdHXN/SP6QQFGFpJRxzkvlVx5HaPu4PlZYqh1Lo2xLoRu7k36I 99xIGjBYkshyqWWUBwpcvkdAQrhXCImh/BqV0YdGR8YX+nBTv0yzgVzr/BFSAYsHas20 KDKg== 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=Phs2DAaIK8MGXZ+i6+CFVkqUm3dtIclSkuWO2pGztkE=; b=JqQp8T5KZZ+fi3ceTaMCUekGob+Wtl9I+zvuBGLXFAsbiVwzgbhO6O5Qrurvv4a4za X/PHbLs6rWi2fPpkb4bDH3Xs1lVmuBOhrjlnUcVKNsBLDpPNwjQEU+Msyq13ZFzFafGj YOF+o8EG4dMcexDFI4glqziqeswlNuAQVsW97+G4sAeaheURkeW352ugpmhEzjUgVZt9 iJXu6M6kD7NEwgN28BD4mmGzpkU2R/VaVBkrI28KU1IKJmh5NfOevrvsOSt4R3jDHJRT Tsklp7PBHVfGZXrn6k2fifYZluv6NwgY2q/sacZrM/a3RoNT0biWrcQl0gj6jp7Uvpr3 jtPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LdCuBNGl; 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 f38si19562113plb.339.2019.05.27.13.55.57; Mon, 27 May 2019 13:55:58 -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=LdCuBNGl; 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 S1727408AbfE0Uz4 (ORCPT + 30 others); Mon, 27 May 2019 16:55:56 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46372 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbfE0Uzt (ORCPT ); Mon, 27 May 2019 16:55:49 -0400 Received: by mail-wr1-f65.google.com with SMTP id r7so17935634wrr.13 for ; Mon, 27 May 2019 13:55:48 -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=Phs2DAaIK8MGXZ+i6+CFVkqUm3dtIclSkuWO2pGztkE=; b=LdCuBNGlJJhVhaMjz2Ob0A6FFGgflwHEr1m4VkQRC8uyp3qf0DtuLOOUf9QDtX0mt7 PXOVc2yDJCfimzO2B8rszVt0iQoABJL3VH9ccDUE02n9TkoGLI2hfkcOzFJjI/FR8f8v 0dR4hOk8/uJBVlWhQvn3jjN2tW46cyldxbjtAH5T//KdZJ8478OoP474TtMz+t4K1W8U V5xNeX1QSOx7LMvHQ9mg8ESQ3XZSnBk8IOyPXzDOvdtaKB4xEf8ZIxdfPCxg7liqthYF SU1smHtrAQX7yNBv6G5jUhIuZaqc4L/qsgC/XSEvSu2ja9XO9XODQscfqn3lPCJQTdZ9 6cBA== 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=Phs2DAaIK8MGXZ+i6+CFVkqUm3dtIclSkuWO2pGztkE=; b=iYq1zPsg+/nuCUkiNM30VP1qy147uJdgGQoAbPMUIM5UKJ2UfKNyamzJw0mr7uX7bB tMH7Q3ZMWkGQCmmibJIQtKG+HvYNdXzhtqAjxdhJ8D+iCvAhjykhl5UNweadFj/GxtyJ /jQZ/1oVSebCThYJhZoUukJWLS5pse9fcE2H525NewjMxwb78YNaK01fUYysvK13uU9s 0wgL9kp3EYhxkX04H+b0Cn2fMrWBJ1cpAXMFV+w/ItrERSR6i1DdaHS8MYdtsqnx6w+r S0J5OxcMYjwfL3MiqWDsq3vajVMtWUlEPNSgivlUplj1u5RDBuXgfK3SpwiBr+1aDliE MwSw== X-Gm-Message-State: APjAAAV3rP8CjnD4c/BVUP5jIOomaKRkvb/D3wnbQUTdhbxS1+ZI5h1t hSRPH2f5O1rPWZJ59XKsXwe4A3D40X4= X-Received: by 2002:adf:e550:: with SMTP id z16mr2515773wrm.146.1558990547233; Mon, 27 May 2019 13:55:47 -0700 (PDT) Received: from clegane.local (30.94.129.77.rev.sfr.net. [77.129.94.30]) by smtp.gmail.com with ESMTPSA id a1sm388565wmj.23.2019.05.27.13.55.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 13:55:46 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com Subject: [PATCH V3 5/8] genirq/timings: Encapsulate storing function Date: Mon, 27 May 2019 22:55:18 +0200 Message-Id: <20190527205521.12091-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190527205521.12091-1-daniel.lezcano@linaro.org> References: <20190527205521.12091-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 1d1c411d4cae..bc04eca6ef84 100644 --- a/kernel/irq/timings.c +++ b/kernel/irq/timings.c @@ -430,11 +430,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 @@ -465,24 +497,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); } /**