linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] raid6_pq: Add module options to prefer algorithm
@ 2018-05-04  0:15 Timofey Titovets
  2019-01-02  2:34 ` Timofey Titovets
  0 siblings, 1 reply; 2+ messages in thread
From: Timofey Titovets @ 2018-05-04  0:15 UTC (permalink / raw)
  To: linux-raid; +Cc: Timofey Titovets, linux-btrfs

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 <nefelim4ag@gmail.com>
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;
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH] raid6_pq: Add module options to prefer algorithm
  2018-05-04  0:15 [RFC PATCH] raid6_pq: Add module options to prefer algorithm Timofey Titovets
@ 2019-01-02  2:34 ` Timofey Titovets
  0 siblings, 0 replies; 2+ messages in thread
From: Timofey Titovets @ 2019-01-02  2:34 UTC (permalink / raw)
  To: linux-raid; +Cc: linux-btrfs

Gentle ping.

пт, 4 мая 2018 г. в 03:15, Timofey Titovets <nefelim4ag@gmail.com>:
>
> 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 <nefelim4ag@gmail.com>
> 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;
> --
> 2.17.0



-- 
Have a nice day,
Timofey.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-02  2:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04  0:15 [RFC PATCH] raid6_pq: Add module options to prefer algorithm Timofey Titovets
2019-01-02  2:34 ` Timofey Titovets

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).