mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Matteo Croce <technoboy85@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KUnit: memcpy: add benchmark
Date: Thu, 29 Jan 2026 15:20:35 -0800	[thread overview]
Message-ID: <20260129152035.1fbdddb214c75875b67ba5b9@linux-foundation.org> (raw)
In-Reply-To: <20260129004328.102770-1-teknoraver@meta.com>

On Thu, 29 Jan 2026 01:43:28 +0100 Matteo Croce <technoboy85@gmail.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();
> +


  reply	other threads:[~2026-01-29 23:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29  0:43 Matteo Croce
2026-01-29 23:20 ` Andrew Morton [this message]
2026-01-29 23:36   ` Matteo Croce
2026-01-29 23:53     ` Andrew Morton
2026-01-30  0:04       ` Matteo Croce
2026-01-30  0:07         ` Matteo Croce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260129152035.1fbdddb214c75875b67ba5b9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=technoboy85@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®