From patchwork Mon May 13 10:29:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 164020 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1141454ili; Mon, 13 May 2019 03:30:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7cxLWZKwS0Xnd3FrAu7ioMN04g+2s5LMlGXTjBZGz5oxDyUYrqnAZV1XJ6c+wD6MjQwvF X-Received: by 2002:a63:d343:: with SMTP id u3mr30027572pgi.285.1557743425704; Mon, 13 May 2019 03:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557743425; cv=none; d=google.com; s=arc-20160816; b=UlcTz4OVciRPRSmU1OmVfmTPZ5I58Sn56SsXtbEJjogbNJF4EOOwBC5LXW068BpBVp Yb6tjvih3gNE/S0VqM9G805zQDzxgpawYvRqV88wLyusXZjCwNItxypLi9hoeBZZQjs2 kblk+M03ixTm4UKoo9N61KdCgEkRAigfXWN+WpjnL7x2u0UJBv48k5+5LJ1gyA3BJI23 3VvxTnHQJyUO8NPXUrU8W8CGB+AUA7nw4XIZiKcjtsn1R/X+KjKF+OywpjdMieA5VML4 EBgxjapTCWsanibe1F+XqiVvweB5bd3w1JUw8jRQkxakYngEygMcjiumoSIBLglS9toq v7KQ== 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=iYRnpnNRQ7/Yn4sCtvCK5+WUBHE5avZWWYPxLbImYZU=; b=PDS2rlsAbwSffDy0nnr7OLddzyVLSCnqmXsR7k4O0Rt4osxyMMPpSHgT+HVcJqwOQO rGHIjODXUazWeQy+OsirtSXVykejzondDVwtA+dx9wXlXwH/+yQSc7gvIntGcC3s8giP haLvrz9VmqIdE5Ue7Hobd10lewXXuhnqtkfr/07DZjYNvcokvF6KFwnbyDHlbwMEqRRM Z2EjTzb0X7xuC+IBQ9q5nRENKc+3laFwULU39tdef9XJS3A/Di7+R36oCbI0/hke8RmA DkNYib0lRjwSkg+dx9qNC6ukpIeikN643u49ZfQ8ULLjT/lk9lfWu0biS0xlCTRpJFWM TU3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UmBOW939; 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 j190si16333590pgd.394.2019.05.13.03.30.25; Mon, 13 May 2019 03:30:25 -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=UmBOW939; 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 S1728816AbfEMKaY (ORCPT + 30 others); Mon, 13 May 2019 06:30:24 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52112 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728653AbfEMKaV (ORCPT ); Mon, 13 May 2019 06:30:21 -0400 Received: by mail-wm1-f65.google.com with SMTP id o189so13314197wmb.1 for ; Mon, 13 May 2019 03:30:20 -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=iYRnpnNRQ7/Yn4sCtvCK5+WUBHE5avZWWYPxLbImYZU=; b=UmBOW939gLTq232p+iwK3f8nCudEncfvXezxIaacngiWvHR8NtB7S5O7nxFq1G9SKz ssd8Zi5tDEqiCdHVFS51Gw4UZYFqp+S7fqqHcqiaXYKet2KtrLRD4PD2VZE59dgrsvkj 3R4liWCFsEBSbG2sUJaHoZ0Uxw3sbivwcwRMp+bY0Xm1ayPdP+ZN8KhMJETc4zqYoZ8o wt2DLh1MiZuUNBhKsYrmewM0i3WxsFP7W4pU5/eGIF0G7ZOQ+c50PZFxrz8wIz4DAg6c zUeryUgBE5tPYqmhPjZvjMcCmCUFy9WkLnU2Mc4tn0/cHh9dF3Sr28aGM8yAVsYnP8x7 r4TQ== 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=iYRnpnNRQ7/Yn4sCtvCK5+WUBHE5avZWWYPxLbImYZU=; b=VOGuMlew3N0vfOTc4bJcwazVoROoZnyvR0f/PrlobpRVzWcN28Mj+2w6wwBJWewUFR OhYyBd+HiTwXCZbEXXRfS6FJyE5DyfxHQ/CVpzMwDZ/16+zK9lVisYyaOdyH2S4uv+7c tWBzPUpNTjiJ9If82jZUeQLC2S5ORo3uAJlIZmIPOSoVmR5ZZGgC332EfLpBc3s8ZOAe 8q/IVef8RLQZsLuonyGpx+e2i/EqjXB+TAOL0Mu8BMbZQlcYLRVm7OHL6NTOUo0yy5Th bAfaDoEW7yGAEpTomJDS/AtWMFEXX/kOVha+/dIFVG01QgF+2mR05qAQcRXmUHUyBF2Z hLyg== X-Gm-Message-State: APjAAAVxo5D98w9+S0vIEl/b6qI80EAoq3hTKXVzLJeMLrnMsEHTXEvD BHP/Ka4AYaZUaattKcPgyp6Fi6mjExo= X-Received: by 2002:a1c:ca08:: with SMTP id a8mr14602038wmg.5.1557743419532; Mon, 13 May 2019 03:30:19 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 03:30:19 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 9/9] genirq/timings: Add selftest for next event computation Date: Mon, 13 May 2019 12:29:53 +0200 Message-Id: <20190513102953.16424-10-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 The circular buffers are now validated at this point with the two previous patches. The next interrupt index algorithm which is the hardest part to validate can be validated with the tests provided with this patch. It uses the intervals stored in the arrays and insert all the values except the last one. The next event computation must return the same value as the last element we did not inserted. Add tests for the next event index computation. Signed-off-by: Daniel Lezcano --- kernel/irq/timings.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) -- 2.17.1 diff --git a/kernel/irq/timings.c b/kernel/irq/timings.c index 5e4efac967fd..eb2bb1d1551f 100644 --- a/kernel/irq/timings.c +++ b/kernel/irq/timings.c @@ -705,6 +705,68 @@ static struct timings_intervals tis[] __initdata = { { intervals4, ARRAY_SIZE(intervals4) }, }; +static int __init irq_timings_test_next_index(struct timings_intervals *ti) +{ + int _buffer[IRQ_TIMINGS_SIZE]; + int buffer[IRQ_TIMINGS_SIZE]; + int index, start, i, count, period_max; + + count = ti->count - 1; + + period_max = count > (3 * PREDICTION_PERIOD_MAX) ? + PREDICTION_PERIOD_MAX : count / 3; + + /* + * Inject all values except the last one which will be used + * to compare with the next index result. + */ + pr_debug("index suite: "); + + for (i = 0; i < count; i++) { + index = irq_timings_interval_index(ti->intervals[i]); + _buffer[i & IRQ_TIMINGS_MASK] = index; + pr_cont("%d ", index); + } + + start = count < IRQ_TIMINGS_SIZE ? 0 : + count & IRQ_TIMINGS_MASK; + + count = min_t(int, count, IRQ_TIMINGS_SIZE); + + for (i = 0; i < count; i++) { + int index = (start + i) & IRQ_TIMINGS_MASK; + buffer[i] = _buffer[index]; + } + + index = irq_timings_next_event_index(buffer, count, period_max); + i = irq_timings_interval_index(ti->intervals[ti->count - 1]); + + if (index != i) { + pr_err("Expected (%d) and computed (%d) next indexes differ\n", + i, index); + return -EINVAL; + } + + return 0; +} + +static int __init irq_timings_next_index_selftest(void) +{ + int i, ret; + + for (i = 0; i < ARRAY_SIZE(tis); i++) { + + pr_info("---> Injecting intervals number #%d (count=%zd)\n", + i, tis[i].count); + + ret = irq_timings_test_next_index(&tis[i]); + if (ret) + break; + } + + return ret; +} + static int __init irq_timings_test_irqs(struct timings_intervals *ti) { struct irqt_stat __percpu *s; @@ -876,6 +938,10 @@ static int __init irq_timings_selftest(void) goto out; ret = irq_timings_irqs_selftest(); + if (ret) + goto out; + + ret = irq_timings_next_index_selftest(); out: pr_info("---------- selftest end with %s -----------\n", ret ? "failure" : "success");