From patchwork Fri May 4 00:15:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 10379493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C8EEE60327 for ; Fri, 4 May 2018 00:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9BB4290E6 for ; Fri, 4 May 2018 00:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D9F12929C; Fri, 4 May 2018 00:16:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B353290E6 for ; Fri, 4 May 2018 00:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751229AbeEDAP7 (ORCPT ); Thu, 3 May 2018 20:15:59 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:38689 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbeEDAP5 (ORCPT ); Thu, 3 May 2018 20:15:57 -0400 Received: by mail-lf0-f65.google.com with SMTP id f18-v6so2862155lfc.5; Thu, 03 May 2018 17:15:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=v5jO8CBfM56ww60GbT3IIKMFCr8Qny6EWLXVFWb/Lyc=; b=UJCujG4W5DVvywEcbUTVljKr0OYQsqZvcXohOjhXzUNg0hQ560H+kFhQ7kwqhmNXMw pI0KimMqwVpHyqDcYEUsnt3+JxfV9tP55Fw1Iv/MlwsGQT1rqb5yXD5WEdjroXiS78c8 iICq7YDl2UE+Fw0hSiWx2EiAbH4jSw039voE9hpaJcbaSpjfYSsvvhBrmEkKGs42nzmJ UkJzlcyDGE9Mb8WQsB13W45UV2xL6KtQDBA8kDPCcT1SR6xq0G6ST8gaxw7bKh7LX/mX hHI7OKhBGUHtguBeCVKy/4AMZjcNOeoBpwdqF5vRjgVbUJwQJb1OCPkNbZHKY9TDTl+G MEag== 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; bh=v5jO8CBfM56ww60GbT3IIKMFCr8Qny6EWLXVFWb/Lyc=; b=l7sX5YiJHdOvDFyWhSKQ3KVvkY0+WOUf3fesbb+y7SgXtFc+9/MW13+pqsHhtonWfY VNGkAx5Yxw+B3j2ZFfUE70rpFDusUdQgYCXwAyiHydKlBM+kmCQIfOmSblpERui0X63M feLIyAmbH2RyvZmD2m32xhXPOEpg9dardIgs39KFKA3vPQyiGhy/rx8k7Im6fg1VzpsR dVfKw/ZyUqK7Nf4pOE3buVkl14PYC2RkJc3NeC+mXzvGBirxc+DJbKR0N2uOWpuva0eO 7ZXDOLy6kTj1A4LTZMuD+66odJKEGvgzSioxhLT+WiQJkXUCBjYr/NVvtFFMO48yrVvU qPbA== X-Gm-Message-State: ALQs6tCEnKAXGT9tnuM4G5vcbYJGQRXF2+L9Y11x+KJHBDgLfSOWge1G XfzM+zDI0kq2Dq15U0jwctrsLw== X-Google-Smtp-Source: AB8JxZphi8yPCmOR3pT5hO43lmo+PqEudVVFmcldWZ5XzzsukE08pvxBqGNv/UlVmEQ7aqGic//mWg== X-Received: by 2002:a19:5386:: with SMTP id h6-v6mr14031647lfl.45.1525392955858; Thu, 03 May 2018 17:15:55 -0700 (PDT) Received: from TitovetsT.lan (mm-59-97-44-37.mgts.dynamic.pppoe.byfly.by. [37.44.97.59]) by smtp.gmail.com with ESMTPSA id a124-v6sm1778966lfe.38.2018.05.03.17.15.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 17:15:55 -0700 (PDT) From: Timofey Titovets To: linux-raid@vger.kernel.org Cc: Timofey Titovets , linux-btrfs@vger.kernel.org Subject: [RFC PATCH] raid6_pq: Add module options to prefer algorithm Date: Fri, 4 May 2018 03:15:41 +0300 Message-Id: <20180504001541.2068-1-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Skip testing unnecessary algorithms to speedup module initialization For my systems: Before: 1.510s (initrd) After: 977ms (initrd) # I set prefer to fastest algorithm Dmesg after patch: [ 1.190042] raid6: avx2x4 gen() 28153 MB/s [ 1.246683] raid6: avx2x4 xor() 19440 MB/s [ 1.246684] raid6: using algorithm avx2x4 gen() 28153 MB/s [ 1.246684] raid6: .... xor() 19440 MB/s, rmw enabled [ 1.246685] raid6: using avx2x2 recovery algorithm Signed-off-by: Timofey Titovets CC: linux-btrfs@vger.kernel.org --- lib/raid6/algos.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c index 5065b1e7e327..abfcb4107fc3 100644 --- a/lib/raid6/algos.c +++ b/lib/raid6/algos.c @@ -30,6 +30,11 @@ EXPORT_SYMBOL(raid6_empty_zero_page); #endif #endif +static char *prefer_name; + +module_param(prefer_name, charp, 0); +MODULE_PARM_DESC(prefer_name, "Prefer gen/xor() algorithm"); + struct raid6_calls raid6_call; EXPORT_SYMBOL_GPL(raid6_call); @@ -155,10 +160,27 @@ static inline const struct raid6_calls *raid6_choose_gen( { unsigned long perf, bestgenperf, bestxorperf, j0, j1; int start = (disks>>1)-1, stop = disks-3; /* work on the second half of the disks */ - const struct raid6_calls *const *algo; - const struct raid6_calls *best; + const struct raid6_calls *const *algo = NULL; + const struct raid6_calls *best = NULL; + + if (strlen(prefer_name)) { + for (algo = raid6_algos; strlen(prefer_name) && *algo; algo++) { + if (!strncmp(prefer_name, (*algo)->name, 8)) { + best = *algo; + break; + } + } + if (!best) + pr_info("raid6: %-8s prefer not found\n", prefer_name); + } + + + + if (!algo) { + algo = raid6_algos; + } - for (bestgenperf = 0, bestxorperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) { + for (bestgenperf = 0, bestxorperf = 0; *algo; algo++) { if (!best || (*algo)->prefer >= best->prefer) { if ((*algo)->valid && !(*algo)->valid()) continue;