From patchwork Wed Nov 6 18:57:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1190625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 477bQG6r59z9sPF; Thu, 7 Nov 2019 05:57:58 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iSQV9-0001mC-8h; Wed, 06 Nov 2019 18:57:55 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iSQV8-0001lX-5y for kernel-team@lists.ubuntu.com; Wed, 06 Nov 2019 18:57:54 +0000 Received: from mail-qk1-f199.google.com ([209.85.222.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iSQV7-000417-UF for kernel-team@lists.ubuntu.com; Wed, 06 Nov 2019 18:57:54 +0000 Received: by mail-qk1-f199.google.com with SMTP id x186so25810544qke.13 for ; Wed, 06 Nov 2019 10:57:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+FXVYBCyfbmeYWv6WZW1g2X0oksktivR4cOctEc2ZNc=; b=QocCc+KCRPQZdo2qeVjH+A0vSQ/adqOzxBKAdEilh+z0BHdW0ZlbvVkyCNoQVW7g31 qCLIwcYhy0y4hzCEDTyugF4EjAhUmruQj1idy8mVsiEMW9hd2ts4H4ldUBEdSeE7bO5m FgcTvXv6KE0BksKZD6oAl5rtohnff6FkQ/bO5tRmsjfh5mToVWnF0x6s8s0bBWBTam28 InGma0ge+QsOS/ySKZ2FbnDcROg3VtbPkX9uiHE7+LEJkFXRG5AQp9eBz1ceb31zlVqg VkJIW8Fhqr9jf8/T7jNBJJMukzbiQoTHEH/JEAm6/JMdTxphn2jqPRYXvgdTN2zdmM5O s6ww== X-Gm-Message-State: APjAAAX/m/EeOFxCBKWE2gl9uaa7hL2BeQ9UMqlpiOPUgE65xvJUgxU6 YZTk2DRXLnx7o9JYyYjgGgf7ew8IBll8KWEcpgM7L5WSnfPa89Hfufgm6GRWJW607o5GDtXYkED zaHtMC6bwBXAAV3SANNctVxV45QL56O/y+Sy7ASi5 X-Received: by 2002:a0c:ca06:: with SMTP id c6mr3593327qvk.136.1573066672604; Wed, 06 Nov 2019 10:57:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxhlNXodhT3jR34Haed7hUf8t7nddUgDMmL9Gg/+KCIrjOGUKAQDlObNXzKfq2mBKQVEBZsDw== X-Received: by 2002:a0c:ca06:: with SMTP id c6mr3593294qvk.136.1573066672155; Wed, 06 Nov 2019 10:57:52 -0800 (PST) Received: from gallifrey.lan ([2804:14c:4e6:443:946b:525b:cf5:2c60]) by smtp.gmail.com with ESMTPSA id s21sm6478841qkg.24.2019.11.06.10.57.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2019 10:57:51 -0800 (PST) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [disco:linux-gcp][PATCH 1/2] UBUNTU: SAUCE: raid6: Add option for default PQ algorithm Date: Wed, 6 Nov 2019 15:57:40 -0300 Message-Id: <20191106185742.5835-4-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191106185742.5835-1-marcelo.cerri@canonical.com> References: <20191106185742.5835-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1812728 BugLink: https://bugs.launchpad.net/bugs/1851538 Add a new config ("CONFIG_RAID6_PQ_DEFAULT_ALG_BOOL") to enable specifying a default gen() algorithm for RAID_PQ via the kernel "raid6_pq_default_alg" cmdline option. When a default algorithm is given, the raid6_pq module will skip the performance round of tests. The config CONFIG_RAID6_PQ_DEFAULT_ALG can be used to define a default value for the kernel option. Signed-off-by: Marcelo Henrique Cerri --- lib/Kconfig | 17 +++++++++++++++++ lib/raid6/algos.c | 26 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/lib/Kconfig b/lib/Kconfig index a9e56539bd11..94635255a996 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -18,6 +18,23 @@ config RAID6_PQ_BENCHMARK Benchmark all available RAID6 PQ functions on init and choose the fastest one. +config RAID6_PQ_DEFAULT_ALG_BOOL + bool "Default RAID6 PQ algorithm" + default n + depends on RAID6_PQ + help + Allow for specifying a default algorithm via the kernel + parameter "raid6_pq_default_alg", which forces the performance + tests to be skipped. This can save between 500ms to 2s + during boot. + +config RAID6_PQ_DEFAULT_ALG + string "Default RAID6 PQ algorithm name" + default "" + depends on RAID6_PQ_DEFAULT_ALG_BOOL + help + The default algorithm name to be used by default. + config BITREVERSE tristate diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c index 7ff2cc789f8a..7e27d1d044d7 100644 --- a/lib/raid6/algos.c +++ b/lib/raid6/algos.c @@ -30,6 +30,12 @@ EXPORT_SYMBOL(raid6_empty_zero_page); #endif #endif +#ifdef CONFIG_RAID6_PQ_DEFAULT_ALG_BOOL +static char raid6_pq_default_alg[32] = CONFIG_RAID6_PQ_DEFAULT_ALG; +module_param_string(raid6_pq_default_alg, raid6_pq_default_alg, sizeof(raid6_pq_default_alg), 0444); +MODULE_PARM_DESC(raid6_pq_default_alg, "Default gen/xor() algorithm"); +#endif + struct raid6_calls raid6_call; EXPORT_SYMBOL_GPL(raid6_call); @@ -158,6 +164,26 @@ static inline const struct raid6_calls *raid6_choose_gen( const struct raid6_calls *const *algo; const struct raid6_calls *best; +#ifdef CONFIG_RAID6_PQ_DEFAULT_ALG_BOOL + if (strlen(raid6_pq_default_alg)) { + for (algo = raid6_algos; *algo; algo++) { + if (!strncmp(raid6_pq_default_alg, (*algo)->name, sizeof(raid6_pq_default_alg))) { + if ((*algo)->valid && !(*algo)->valid()) { + pr_info("raid6: default alg \"%s\" is invalid.\n", + raid6_pq_default_alg); + continue; + } + pr_info("raid6: using default algorithm %s gen() without performace tests.\n", + (*algo)->name); + raid6_call = **algo; + return *algo; + } + } + pr_info("raid6: default alg \"%s\" not found. Choosing the best alg as fallback...\n", + raid6_pq_default_alg); + } +#endif + for (bestgenperf = 0, bestxorperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) { if (!best || (*algo)->prefer >= best->prefer) { /* 2 ^ (RAID6_TIME_JIFFIES_LG2 - 0.5) */