From patchwork Mon May 27 20:55:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 165230 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7616689ili; Mon, 27 May 2019 13:56:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7CMctgFC3hUcjRpGmbnX3a/MYSd9GQG/r3pFUl2QCc+z+LQEo05j8xc+MdqUaBV0nU7VW X-Received: by 2002:a17:90a:e17:: with SMTP id v23mr817248pje.139.1558990563435; Mon, 27 May 2019 13:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558990563; cv=none; d=google.com; s=arc-20160816; b=Xd91FpecPzGiMO8CDXsubLFWZoSx/mP7C0gaVzo2/2dTNtTYA6cl6YUc3GLaLs1fTP omdZlA24D7GZfVebJCHCeZtdQht1K4Zxw5As0t6J+NulQj3rYmkqI8eRm3h5Zpkfe2mR +uGKH+8quh0O8yxO5gTNheQPD8Dtk3bVAVI8RqTrI2VnytMVI7I5YTeP5rvUcVbxqXb9 BFe42mDOwLRHElCbmcOhmX3mxR81ZW/4PucK5QJqsBp1uAVAkqtXw2cyHNRGJjVfzXEZ 3G5B92Szm9tlnFPMb6O8iA9mBLKxu4ZKLsMt8nCdmDsBxpzYv/Gn8QrC//jwJphyVNDM njKw== 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=dfUdgBJPtbCYc/uhDOpMaPmMlc4FCxxcnSQ96C7YgX8=; b=fgX10p4bW1MKtwBt6PZj9ULhpoNeD7K89cqHfFvnw+7kO+nncoFgoblL4KABYw9OkZ lCZcibiplEPOQdMakvUSOyM0g/DckbQynNPvQqN/IVx+3EsxJeyr/uI16OiMJGvacR9L 3xWkkERhYMrvnCivaMSRBAkCJVZT0VK/qnDnTGwDwL4yuuKFlsbPkPnztJxIRlulNefC XT53aQokOJ5nT+yyBEXuj040Z8SDmhywezSjvkhwSEMCpp10H1cSG9KvFROQPm21d4i9 6xT7b5gXWfyvWgkisZmAjG9GKuB2/pjj2Dzy5Ztsdm4vsnp6lMrvm3YspXKc7NR7/+vo 3OFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pC54YjrC; 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 q14si17966816pls.327.2019.05.27.13.56.03; Mon, 27 May 2019 13:56: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=pC54YjrC; 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 S1727443AbfE0U4C (ORCPT + 30 others); Mon, 27 May 2019 16:56:02 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35834 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727377AbfE0Uzx (ORCPT ); Mon, 27 May 2019 16:55:53 -0400 Received: by mail-wr1-f66.google.com with SMTP id m3so17972481wrv.2 for ; Mon, 27 May 2019 13:55:51 -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=dfUdgBJPtbCYc/uhDOpMaPmMlc4FCxxcnSQ96C7YgX8=; b=pC54YjrChaPbEwjQzWzOtVgI4Qfy3JE7gSPnbvirKitnpg3zXdThxMKqBnbW0zLitf jWYAtQll0nL4ZAuDMmHjmhAkzIf3BJu+eYMOe4FF/9oDdQtnjBlKRfwj12q83g+pP6Nf N0TYoOM1d12w6pdxrm/ChgZ11uOOiGKs4fWblPpQis91t42RBRyKETFU1v9rtKpEOTW+ oYKjOELW3eM9GpBHBb+kTK/vpnn197yu+CoKaQigoLQI+JJiaNSMjekcIJERuCiwG9CW kbtLh+PZXbaiooedeV2h00nqAD6L/4YJIcUHbNw+0UbWpP67iVJoMuF9MSPvHbGsPTJh u1VQ== 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=dfUdgBJPtbCYc/uhDOpMaPmMlc4FCxxcnSQ96C7YgX8=; b=fvctPqJ/fmwPbyWCEHJxrwgtye9gae44Te4NIDBS6h7v/v6R9Xh3IAQnPTDedDuHtI U4l5AnMTVpOBmNCN/yp6fnOMj1tl/koQUU3aIE/ct0glGuEXZ7FRnBvMg8uNUzpHp/jw JUdLKKKrVU761YewUO3hwL1LbnjO9tehlTvogEyagG69/QfjlfhhEWLe6+3R3KjWflmY ip7jYC8jpBIYt4U98vWtA1Q7lNPH6kqErfSTTEvxDybLiuvgKIZYE7Um/LYNU0f/MqBz iTSaRciSTrGC1+TuQgZpK4dV7sicTI5Tk7H3lurQAPDRXRdC/PWFn1o39qL2ZSPZIg4S 1gkQ== X-Gm-Message-State: APjAAAVWVghIr7U8k3ImBKw9e+j80bUVZH54wvbFET5aXUtiodYmK23Q BNhoWdTB5nwFnjlGJYUvvDfDpQ== X-Received: by 2002:a5d:694a:: with SMTP id r10mr7803842wrw.345.1558990551007; Mon, 27 May 2019 13:55:51 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 13:55:50 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com Subject: [PATCH V3 8/8] genirq/timings: Add selftest for next event computation Date: Mon, 27 May 2019 22:55:21 +0200 Message-Id: <20190527205521.12091-9-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 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 5b13c2231d4f..e960d7ce7bcc 100644 --- a/kernel/irq/timings.c +++ b/kernel/irq/timings.c @@ -704,6 +704,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; @@ -875,6 +937,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");