From patchwork Mon May 27 20:55:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 165229 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7616658ili; Mon, 27 May 2019 13:56:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwX5ZGDQwxr+wiACRdAJUqNk7q1Mp2C9r3CRSbj07ZCf1yH//08J+xpUzrU0hJsmdysSV09 X-Received: by 2002:a17:902:2883:: with SMTP id f3mr22640576plb.111.1558990561098; Mon, 27 May 2019 13:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558990561; cv=none; d=google.com; s=arc-20160816; b=OXMZ3EPesb3XXDOaI/Mr3qUmKJUEK7JlWH8Ean+mLyj99bx/ZeieZP+VvDq+cfDvnz p6prDYdtf4lJu0AeLBGyreBZw7qgeiVxYp6Wk4ChgdVTPmOYsyMQuScmPDmtG+A4L9zj pmdVnBOrvQYnaWgRzN4NUqn+gS8q7SJsSV1F+IXraA/HPpvMAZtkj1Q//SjCPmho2qIx YzfRSLVo2SAVeKKpOBXF3xuLQDfRDVNA6zt9AqicITwLjVnjp++4DdtyTfPSrjIz9UOF yCSxnr0G0O6JaIIHP7qZWOEtKT6kAbP/nKjAwd17i17WSrSxFRE0xbR9PvsAw1KyPfaQ p1gw== 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=MjZ/pyBZBO4EDEwBpRQ6u4NGJabjhPzRMD0kf65cmv4=; b=IFllZ/Hl/kQMuPTpvaRKtrJGchkMoLEZu/kNHIA+JgNMZ2a9e36FVbyXrRIexWrkzF SaC9qTM/m0KscsuXo/7OxnuRoy3CI4/aYLixems7fnk+KW3dNEf63bZz91R5laq9gaJr Kq4M1aYGhKZe1HMcpb2PLvmvpOeU1oAtYkVFHbc1klRdoO/7mK5MGLiTSr8DPCp99ZqT jsLN1IRqKdv8+wATytIjEzoudPayxCblaXHTmlSp69XsO6HQSNzvx/7VXZVr952FenwV lLzkdJvHJXTVDLgIzGMz/SU0wVEhG95nsLST9rAJAvC2kNBr3H6ormvBU1h2N9+El/cW 0xmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GauBSKsf; 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 p19si15776044plq.47.2019.05.27.13.56.00; Mon, 27 May 2019 13:56:01 -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=GauBSKsf; 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 S1727428AbfE0U4A (ORCPT + 30 others); Mon, 27 May 2019 16:56:00 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33923 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727347AbfE0Uzw (ORCPT ); Mon, 27 May 2019 16:55:52 -0400 Received: by mail-wr1-f68.google.com with SMTP id f8so17983466wrt.1 for ; Mon, 27 May 2019 13:55:50 -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=MjZ/pyBZBO4EDEwBpRQ6u4NGJabjhPzRMD0kf65cmv4=; b=GauBSKsfWkUC1ndbG21MewLXH8aQTbFfRtmwE0QfKWksuLdU2V1AKi/7bMLplJEzFB iY9xU9FbZht/hZvDRZy9xMUArd2o68734zpvMaqgR7NMp2JdO64lYu9Dgrq1PhGr5NdZ SvU8RmB3ilA1vCA4eVEZMCX//zKV/Y1DCLC8DKrbDPDgwCUgqnX/soDbKfneUKT4PEtI l1wCyjU9aTn5gyWosMH8wB7Uvmk4wZW9qDnGZXHe0+uoNyjs8vsdW2O/WrzgQxWLcQCV j9YBuE/dtDIavmPTLvz+k8rSg3IP+4fzrhfXKl3wvLnuURZQkb1Kr9IyEcHOxg9oCXVY jTzg== 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=MjZ/pyBZBO4EDEwBpRQ6u4NGJabjhPzRMD0kf65cmv4=; b=sMNTeibdCNOzEz73FVw7Zj2YkMuKiTckCK8R0rkGN7xb+G8Mr/qXPvV7F7IQdembcb aD69ObwQh9m4MkDeD11HRd0F8JMcRFufJH+TIJgRwKwqV5eEm3JzFbla0p6Yl6OoZ/qK fy+uuQVe67vS90RmlkY1sgeJHlgAddUYhH39h4aZGRNRcotYp4rEXAiej8hx6ZCE1Bse bzC2cmCztPZavrI95odnNxk7ukgARdCzo+sLevPIaiIA2ykLIaGxlaT2G81Z4vXNQEQs xDYBNv4yko3J7xH5QF8f0bVZzU7dnr8givTTQFt034DmNC0VHq4V6i9oC/3iUPHqCMjK vsjw== X-Gm-Message-State: APjAAAXIW9QznEVK8Y0/a/98wb+LWkU8PFktNkwd9sZQ4qS5I3Mt681d N7X09SBmtC700MW45HsOEJ9JLg== X-Received: by 2002:a5d:504f:: with SMTP id h15mr307455wrt.208.1558990549613; Mon, 27 May 2019 13:55:49 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 13:55:48 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com Subject: [PATCH V3 7/8] genirq/timings: Add selftest for irqs circular buffer Date: Mon, 27 May 2019 22:55:20 +0200 Message-Id: <20190527205521.12091-8-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 After testing the per cpu interrupt circular event, we want to make sure the per interrupt circular buffer usage is correct. Add tests to validate the interrupt circular buffer. Signed-off-by: Daniel Lezcano --- kernel/irq/timings.c | 139 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) -- 2.17.1 diff --git a/kernel/irq/timings.c b/kernel/irq/timings.c index 95b63bdea156..5b13c2231d4f 100644 --- a/kernel/irq/timings.c +++ b/kernel/irq/timings.c @@ -629,6 +629,141 @@ int irq_timings_alloc(int irq) } #ifdef CONFIG_TEST_IRQ_TIMINGS +struct timings_intervals { + u64 *intervals; + size_t count; +}; + +/* + * Intervals are given in nanosecond base + */ +static u64 intervals0[] __initdata = { + 10000, 50000, 200000, 500000, + 10000, 50000, 200000, 500000, + 10000, 50000, 200000, 500000, + 10000, 50000, 200000, 500000, + 10000, 50000, 200000, 500000, + 10000, 50000, 200000, 500000, + 10000, 50000, 200000, 500000, + 10000, 50000, 200000, 500000, + 10000, 50000, 200000, +}; + +static u64 intervals1[] __initdata = { + 223947000, 1240000, 1384000, 1386000, 1386000, + 217416000, 1236000, 1384000, 1386000, 1387000, + 214719000, 1241000, 1386000, 1387000, 1384000, + 213696000, 1234000, 1384000, 1386000, 1388000, + 219904000, 1240000, 1385000, 1389000, 1385000, + 212240000, 1240000, 1386000, 1386000, 1386000, + 214415000, 1236000, 1384000, 1386000, 1387000, + 214276000, 1234000, +}; + +static u64 intervals2[] __initdata = { + 4000, 3000, 5000, 100000, + 3000, 3000, 5000, 117000, + 4000, 4000, 5000, 112000, + 4000, 3000, 4000, 110000, + 3000, 5000, 3000, 117000, + 4000, 4000, 5000, 112000, + 4000, 3000, 4000, 110000, + 3000, 4000, 5000, 112000, + 4000, +}; + +static u64 intervals3[] __initdata = { + 1385000, 212240000, 1240000, + 1386000, 214415000, 1236000, + 1384000, 214276000, 1234000, + 1386000, 214415000, 1236000, + 1385000, 212240000, 1240000, + 1386000, 214415000, 1236000, + 1384000, 214276000, 1234000, + 1386000, 214415000, 1236000, + 1385000, 212240000, 1240000, +}; + +static u64 intervals4[] __initdata = { + 10000, 50000, 10000, 50000, + 10000, 50000, 10000, 50000, + 10000, 50000, 10000, 50000, + 10000, 50000, 10000, 50000, + 10000, 50000, 10000, 50000, + 10000, 50000, 10000, 50000, + 10000, 50000, 10000, 50000, + 10000, 50000, 10000, 50000, + 10000, +}; + +static struct timings_intervals tis[] __initdata = { + { intervals0, ARRAY_SIZE(intervals0) }, + { intervals1, ARRAY_SIZE(intervals1) }, + { intervals2, ARRAY_SIZE(intervals2) }, + { intervals3, ARRAY_SIZE(intervals3) }, + { intervals4, ARRAY_SIZE(intervals4) }, +}; + +static int __init irq_timings_test_irqs(struct timings_intervals *ti) +{ + struct irqt_stat __percpu *s; + struct irqt_stat *irqs; + int i, index, ret, irq = 0xACE5; + + ret = irq_timings_alloc(irq); + if (ret) { + pr_err("Failed to allocate irq timings\n"); + return ret; + } + + s = idr_find(&irqt_stats, irq); + if (!s) { + ret = -EIDRM; + goto out; + } + + irqs = this_cpu_ptr(s); + + for (i = 0; i < ti->count; i++) { + + index = irq_timings_interval_index(ti->intervals[i]); + pr_debug("%d: interval=%llu ema_index=%d\n", + i, ti->intervals[i], index); + + __irq_timings_store(irq, irqs, ti->intervals[i]); + if (irqs->circ_timings[i & IRQ_TIMINGS_MASK] != index) { + pr_err("Failed to store in the circular buffer\n"); + goto out; + } + } + + if (irqs->count != ti->count) { + pr_err("Count differs\n"); + goto out; + } + + ret = 0; +out: + irq_timings_free(irq); + + return ret; +} + +static int __init irq_timings_irqs_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_irqs(&tis[i]); + if (ret) + break; + } + + return ret; +} + static int __init irq_timings_test_irqts(struct irq_timings *irqts, unsigned count) { @@ -736,7 +871,11 @@ static int __init irq_timings_selftest(void) } ret = irq_timings_irqts_selftest(); + if (ret) + goto out; + ret = irq_timings_irqs_selftest(); +out: pr_info("---------- selftest end with %s -----------\n", ret ? "failure" : "success");