From patchwork Fri May 24 11:16:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 165110 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3437648ili; Fri, 24 May 2019 04:17:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRfC1avwZoeXi5bIS2Aaj/WYUhawFd/p5IyCYGutGNrobAL1pwCE/hvxJ7cdAwMcw27lq+ X-Received: by 2002:a17:90a:7344:: with SMTP id j4mr8596919pjs.71.1558696623634; Fri, 24 May 2019 04:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558696623; cv=none; d=google.com; s=arc-20160816; b=o43L3OWnPc2qK+k55t/GvfgVIWWp/2Pq7TODBDgooag5xhhit97ZDhKJMcjLyMP5KL 4TxwIIM0eGsD6Lz3qY7a8vA40WkAKICzau93dlys4wsW1Nv5vzUmL+HQrc7kt7R6B949 oKz1CmS5YLBOfsXWnMQg1edW8xvVhxQsUC8QoHlmLjVymfOW/EcBBrPwzpNSceD1F6IL k5XUpFcWq9BucK43AA273+1wzZgKSKITyQby4O3RSBMwtqm4BOfMpOrzqC7IfGFA8Xnr b4AlnXJi97Ayj/wLYMjKtt+A/RCncaC4SCJV3+Xnq2bElYzS8oUwvxuGd5PZ4+iv5aBe hYIA== 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=G5nxOdBUznUhFtrsyw6jn0DB5+V+OpYGR3SWnQZ3DIscAD35Mh1sADLiqPZkrCC3lf kVH1CAu6Hxi7svwEeOFsmXkusxSqD3NOmPGH6VGUJEaBhozAftaC5+oDeISoWC1dgQah KSaCHbL+x4P5qidhdH5vUWpewE8I7dXsH9uXT8O1bHfP+9cMCJwwcmKWyZSVqR8zRIxq qmImr9suuoTFcVe6jzaOjBI6u6mT5FHUHRUGzvVN1FJHnWzrtrDYcZjXVgg0T0n5fKlm F1RobTD9KCziV+IulYZ1q56rLR4lQ3IQBsaKh1behW9JpTkNE4Fnkj90X4/1vXRyNSid 9Nzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rnm0jHfA; 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 k19si3674055pgh.143.2019.05.24.04.17.03; Fri, 24 May 2019 04:17:03 -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=rnm0jHfA; 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 S2391103AbfEXLRC (ORCPT + 30 others); Fri, 24 May 2019 07:17:02 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35452 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390960AbfEXLQy (ORCPT ); Fri, 24 May 2019 07:16:54 -0400 Received: by mail-wm1-f68.google.com with SMTP id w9so2700021wmi.0 for ; Fri, 24 May 2019 04:16:53 -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=rnm0jHfAzJ1AP8s88sisdQZ5nQbg3x8BdKbT5ATKq3y8Rvvg9GMLdi6LmAr+t24XxH 03Vl+bouHsiOY+/gkQ+nvo6h3zSCgChzAps95hweWo4EBPX2zO3Vt4gJisiMLRZx7dY6 XJEUp0L8pwD7v3nEeGEGFK44YIHBQWOZJHbgy+qNI+JUXwsnxa312EB1BG1g1Zscl0Ys Jk7JXT4zBXaOEDe/2DlkX4b3mEtotUM+OB6ji+4Rp60zc++vNUhBVERvBjnkDB4XVPcY jF7HD9bUDWqXH1YggzwV8bSzP3HKTaK7zsrwSTFyJgfHJ2BohOyTD6UqFtInrB8PfosK LHtA== 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=Vs7YNgsJzQXce83BA+8XX5rv/MmCN6xfydM2iMLPR0tc3SaZJokV1JWgcM0AmHnJ4V 9T1NPsYoe7Sd65vnts5HVXmiAyIqV2QR1+1ciPW+TLcHABa1rUEeK1QKtWT7OHc9yR7G 7pJzx44xO72bakfGNji1Yzb0fnmyOp5hRk4AdpgsE5iqKa5gHrJKIKZv6jf5nh3Nc6Wq N8TwL/Mrc4szZSvsG9l85DYhApFqK17YvzyXqJc7gDmeueyPh0B1QvGTjkN9ihFENN3o Qeor6WD7R47mUl6VEa8sZUR83rUWWyhWQFQ1DAV1G6PgHjtNieuDkIZUKYctLkvTs9NM 7/Dg== X-Gm-Message-State: APjAAAWTppLanfu3II6NwljsqSIqfWvBGep0kKqeSexzfPqGJrUYe5Z9 mkLQpsRDdA2jdjKwj/RhNebYHA== X-Received: by 2002:a7b:c765:: with SMTP id x5mr9377556wmk.26.1558696612702; Fri, 24 May 2019 04:16:52 -0700 (PDT) Received: from clegane.local (73.82.95.92.rev.sfr.net. [92.95.82.73]) by smtp.gmail.com with ESMTPSA id h12sm2575392wre.14.2019.05.24.04.16.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 04:16:52 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com Subject: [PATCH V2 9/9] genirq/timings: Add selftest for next event computation Date: Fri, 24 May 2019 13:16:15 +0200 Message-Id: <20190524111615.4891-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190524111615.4891-1-daniel.lezcano@linaro.org> References: <20190524111615.4891-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");