[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260129152035.1fbdddb214c75875b67ba5b9@linux-foundation.org>
Date: Thu, 29 Jan 2026 15:20:35 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Matteo Croce <technoboy85@...il.com>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KUnit: memcpy: add benchmark
On Thu, 29 Jan 2026 01:43:28 +0100 Matteo Croce <technoboy85@...il.com> wrote:
> Add optional benchmarks for memcpy() and memmove() functions.
> Each benchmark is run twice: first with buffers aligned and then with
> buffers unaligned, to spot unaligned accesses on platforms where they
> have a noticeable performance impact.
>
> ...
>
> +static int memcpy_bench_align(struct kunit *test, bool unalign)
> +{
> + u64 start, end, total_ns = 0;
> + char *buf1;
> + char *buf2;
> + int ret = 0;
> +
> + buf1 = kzalloc(COPY_SIZE, GFP_KERNEL);
> + if (!buf1)
> + return -ENOMEM;
> +
> + buf2 = kzalloc(COPY_SIZE, GFP_KERNEL);
> + if (!buf2) {
> + ret = -ENOMEM;
> + goto out_free;
> + }
> +
> + preempt_disable();
> + for (int i = 0; i < COPIES_NUM; i++) {
> + start = ktime_get_ns();
> + memcpy(buf1 + unalign, buf2, COPY_SIZE - unalign);
> + end = ktime_get_ns();
> + total_ns += end - start;
> + cond_resched();
Is cond_resched() inside preempt_disable() actually legal?
Might be, but it doesn't make a lot of sense, does it?
> + }
> + preempt_enable();
> +
Powered by blists - more mailing lists