[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <53e91f9f-bfe5-5c57-157c-fc456bd430ca@inria.fr>
Date: Thu, 30 Oct 2025 11:12:33 +0100 (CET)
From: Julia Lawall <julia.lawall@...ia.fr>
To: Markus Elfring <Markus.Elfring@....de>
cc: cocci@...ia.fr, LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org, Miaoqian Lin <linmq006@...il.com>
Subject: Re: [cocci] [RFC] Increasing usage of direct pointer assignments
from memcpy() calls with SmPL?
On Thu, 30 Oct 2025, Markus Elfring wrote:
> >> It can be determined then from the generated diff file that mentioned
> >> implementation details can be transformed in 304 source files at the moment.
> >> Thus I became curious if it would be supported to adjust any places there
> >> according to (Linux) coding style preferences.
> >
> > If you have a concern, you have to say what it is.
>
> I expressed something for further development considerations.
> The source code analysis result can be interpreted in some directions.
>
>
> > It doesn't seem it is
> > about the running time,
>
> Not directly in this case.
>
>
> > so why do you include that information?
>
> Further software users can compare such a measurement with other observations.
>
>
> > I should not have to repeat your experiment to figure out what you are
> > asking about.
>
> You can recognise recurring development challenges, can't you?
>
> * Change resistance
>
> * Varying coding style preferences
>
> * Code improvement possibilities
>
> * Development resources
>
> * Pretty-printing issues
>
>
> Another test result representation for your convenience:
> https://elixir.bootlin.com/linux/v6.18-rc3/source/arch/arm64/kvm/arm.c#L2554-L2726
>
> Markus_Elfring@...ne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --no-loops …/Projekte/Coccinelle/janitor/use_memcpy_assignment.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());
> kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu] = (unsigned long)page_addr;
This is all I wanted. The rest is complete noise.
I think you would get a more satisfactory result by just removing all of
the code and adding it back. Then Coccinelle would take charge of laying
out the whole thing.
thanks,
julia
> }
>
>
> real 0m0,606s
> user 0m0,576s
> sys 0m0,030s
>
>
>
> Another SmPL script example might become helpful.
>
> @replacement2@
> expression object, size, source, target;
> @@
> target =
> - object; memcpy(target, source, size)
> + memcpy(object, source, size)
> ;
>
>
> Markus_Elfring@...ne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --no-loops …/Projekte/Coccinelle/janitor/use_memcpy_assignment2.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());
> kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu] = (unsigned long)page_addr;
> }
>
>
> real 0m0,626s
> user 0m0,588s
> sys 0m0,037s
>
>
> Regards,
> Markus
>
Powered by blists - more mailing lists