mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: cocci@inria.fr, LKML <linux-kernel@vger.kernel.org>,
	 kernel-janitors@vger.kernel.org,
	Miaoqian Lin <linmq006@gmail.com>
Subject: Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
Date: Thu, 30 Oct 2025 13:31:49 +0100 (CET)	[thread overview]
Message-ID: <aa99eded-be51-af3b-414-7c3bbaddea4a@inria.fr> (raw)
In-Reply-To: <60f881dc-979d-486b-95be-6b31e85d4041@web.de>

[-- Attachment #1: Type: text/plain, Size: 2790 bytes --]



On Thu, 30 Oct 2025, Markus Elfring wrote:

> > If you have a concern, you have to say what it is.  It doesn't seem it is
> > about the running time, so why do you include that information?
>
> How will remaining open issues be resolved?
>
>
> > I should not have to repeat your experiment
>
> It would be nice if further software users would occasionally reproduce
> presented data processing possibilities.
>
>
> >                                             to figure out what you are
> > asking about.
>
> I “accidentally” tried also the following SmPL script variants out.
>
> A)
> @replacement3@
> expression object, size, source, target;
> @@
>  target =
> -object; memcpy(target, source, size)
> +object; memcpy(object, source, size)
>  ;
>
> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --no-loops …/Projekte/Coccinelle/janitor/use_memcpy_assignment3.cocci arch/arm64/kvm/arm.c
> …
> @@ -2600,8 +2600,8 @@ static int __init init_hyp_mode(void)
>                         goto out_err;
>                 }
>
> -               page_addr = page_address(page);
> -               memcpy(page_addr, CHOOSE_NVHE_SYM(__per_cpu_start), nvhe_percpu_size());
> +               page_addr =memcpy(page_address(page), CHOOSE_NVHE_SYM(__per_cpu_start),
> +                                 nvhe_percpu_size());page_address(page);
>                 kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu] = (unsigned long)page_addr;
>         }
>
>
> real    0m0,578s
> user    0m0,524s
> sys     0m0,047s
>
>
>
> B)
> @replacement4@
> expression object, size, source, target;
> @@
> -target = object; memcpy(target, source, size)
> +target = object; memcpy(object, source, size)
>  ;
>
> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --no-loops …/Projekte/Coccinelle/janitor/use_memcpy_assignment4.cocci arch/arm64/kvm/arm.c
> …
> @@ -2600,8 +2600,8 @@ static int __init init_hyp_mode(void)
>                         goto out_err;
>                 }
>
> +               memcpy(page_address(page), CHOOSE_NVHE_SYM(__per_cpu_start), nvhe_percpu_size());
>                 page_addr = page_address(page);
> -               memcpy(page_addr, CHOOSE_NVHE_SYM(__per_cpu_start), nvhe_percpu_size());
>                 kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu] = (unsigned long)page_addr;
>         }

Not sure what is the point of all this.  Try:

- target = object; memcpy(target, source, size);
+ target = memcpy(target, source, size);

Then it will add newlines in the argument of memcpy if needed to stay in a
reasonable number of columns.

julia

>
>
> real    0m0,565s
> user    0m0,533s
> sys     0m0,032s
>
>
>
> Would you like to reconsider implementation details accordingly?
>
> Regards,
> Markus
>

  reply	other threads:[~2025-10-30 12:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29 19:56 Markus Elfring
2025-10-29 21:24 ` [cocci] " Julia Lawall
2025-10-30  9:33   ` Markus Elfring
2025-10-30 10:12     ` Julia Lawall
2025-10-30 10:19       ` Markus Elfring
2025-10-30 10:32         ` Julia Lawall
2025-10-30 12:26   ` Markus Elfring
2025-10-30 12:31     ` Julia Lawall [this message]
2025-10-30 13:35       ` Markus Elfring
2025-10-30 13:38         ` Julia Lawall
2025-10-30 13:47       ` Dan Carpenter
2025-10-30 13:58         ` Markus Elfring
2025-10-31  6:00         ` Markus Elfring
2025-10-30 14:06   ` Markus Elfring
2025-10-30 14:14     ` Julia Lawall
2025-10-30 14:22       ` Markus Elfring

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=aa99eded-be51-af3b-414-7c3bbaddea4a@inria.fr \
    --to=julia.lawall@inria.fr \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linmq006@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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®