* [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
@ 2025-10-29 19:56 Markus Elfring
2025-10-29 21:24 ` Julia Lawall
0 siblings, 1 reply; 17+ messages in thread
From: Markus Elfring @ 2025-10-29 19:56 UTC (permalink / raw)
To: cocci; +Cc: LKML, kernel-janitors, Miaoqian Lin
Hello,
I got into the mood to try another simple source code transformation out which
can be achieved also by the means of the semantic patch language.
@replacement@
expression object, size, source, target;
@@
target =
- object;
memcpy(
- target
+ object
, source,
size);
Test result (according to the software combination “Coccinelle 1.3.0”):
Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --timeout 23 -j4 --chunksize 1 --no-loops -dir . …/Projekte/Coccinelle/janitor/use_memcpy_assignment.cocci > …/Projekte/Bau/Linux/scripts/Coccinelle/use_memcpy_assignment-no_loops-20251029.diff 2> …/Projekte/Bau/Linux/scripts/Coccinelle/use_memcpy_assignment-no_loops-errors-20251029.txt
real 5m35,579s
user 20m20,037s
sys 0m14,467s
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.
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-29 19:56 [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL? Markus Elfring
@ 2025-10-29 21:24 ` Julia Lawall
2025-10-30 9:33 ` Markus Elfring
` (3 more replies)
0 siblings, 4 replies; 17+ messages in thread
From: Julia Lawall @ 2025-10-29 21:24 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci, LKML, kernel-janitors, Miaoqian Lin
[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]
On Wed, 29 Oct 2025, Markus Elfring wrote:
> Hello,
>
> I got into the mood to try another simple source code transformation out which
> can be achieved also by the means of the semantic patch language.
>
> @replacement@
> expression object, size, source, target;
> @@
> target =
> - object;
> memcpy(
> - target
> + object
> , source,
> size);
>
>
> Test result (according to the software combination “Coccinelle 1.3.0”):
> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --timeout 23 -j4 --chunksize 1 --no-loops -dir . …/Projekte/Coccinelle/janitor/use_memcpy_assignment.cocci > …/Projekte/Bau/Linux/scripts/Coccinelle/use_memcpy_assignment-no_loops-20251029.diff 2> …/Projekte/Bau/Linux/scripts/Coccinelle/use_memcpy_assignment-no_loops-errors-20251029.txt
> real 5m35,579s
> user 20m20,037s
> sys 0m14,467s
>
>
> 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. It doesn't seem it is
about the running time, so why do you include that information?
I should not have to repeat your experiment to figure out what you are
asking about.
julia
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-29 21:24 ` Julia Lawall
@ 2025-10-30 9:33 ` Markus Elfring
2025-10-30 10:12 ` Julia Lawall
2025-10-30 12:26 ` Markus Elfring
` (2 subsequent siblings)
3 siblings, 1 reply; 17+ messages in thread
From: Markus Elfring @ 2025-10-30 9:33 UTC (permalink / raw)
To: Julia Lawall, cocci; +Cc: LKML, kernel-janitors, Miaoqian Lin
>> 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@Sonne:…/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;
}
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@Sonne:…/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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 9:33 ` Markus Elfring
@ 2025-10-30 10:12 ` Julia Lawall
2025-10-30 10:19 ` Markus Elfring
0 siblings, 1 reply; 17+ messages in thread
From: Julia Lawall @ 2025-10-30 10:12 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci, LKML, kernel-janitors, Miaoqian Lin
[-- Attachment #1: Type: text/plain, Size: 3312 bytes --]
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@Sonne:…/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@Sonne:…/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
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 10:12 ` Julia Lawall
@ 2025-10-30 10:19 ` Markus Elfring
2025-10-30 10:32 ` Julia Lawall
0 siblings, 1 reply; 17+ messages in thread
From: Markus Elfring @ 2025-10-30 10:19 UTC (permalink / raw)
To: Julia Lawall, cocci; +Cc: LKML, kernel-janitors, Miaoqian Lin
…> 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.
…
See also once more:
>> 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@Sonne:…/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
…>> real 0m0,626s
>> user 0m0,588s
>> sys 0m0,037s
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 10:19 ` Markus Elfring
@ 2025-10-30 10:32 ` Julia Lawall
0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2025-10-30 10:32 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci, LKML, kernel-janitors, Miaoqian Lin
[-- Attachment #1: Type: text/plain, Size: 861 bytes --]
On Thu, 30 Oct 2025, Markus Elfring wrote:
> …> 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.
> …
>
> See also once more:
>
> >> Another SmPL script example might become helpful.
> >>
> >> @replacement2@
> >> expression object, size, source, target;
> >> @@
> >> target =
> >> - object; memcpy(target, source, size)
> >> + memcpy(object, source, size)
> >> ;
I said to remove everything. target = also.
julia
> >>
> >>
> >> Markus_Elfring@Sonne:…/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
> …>> real 0m0,626s
> >> user 0m0,588s
> >> sys 0m0,037s
>
>
> Regards,
> Markus
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-29 21:24 ` Julia Lawall
2025-10-30 9:33 ` Markus Elfring
@ 2025-10-30 12:26 ` Markus Elfring
2025-10-30 12:31 ` Julia Lawall
2025-10-30 14:06 ` Markus Elfring
2025-10-31 16:57 ` Markus Elfring
3 siblings, 1 reply; 17+ messages in thread
From: Markus Elfring @ 2025-10-30 12:26 UTC (permalink / raw)
To: Julia Lawall, cocci; +Cc: LKML, kernel-janitors, Miaoqian Lin
> 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;
}
real 0m0,565s
user 0m0,533s
sys 0m0,032s
Would you like to reconsider implementation details accordingly?
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 12:26 ` Markus Elfring
@ 2025-10-30 12:31 ` Julia Lawall
2025-10-30 13:35 ` Markus Elfring
2025-10-30 13:47 ` Dan Carpenter
0 siblings, 2 replies; 17+ messages in thread
From: Julia Lawall @ 2025-10-30 12:31 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci, LKML, kernel-janitors, Miaoqian Lin
[-- 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
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 12:31 ` Julia Lawall
@ 2025-10-30 13:35 ` Markus Elfring
2025-10-30 13:38 ` Julia Lawall
2025-10-30 13:47 ` Dan Carpenter
1 sibling, 1 reply; 17+ messages in thread
From: Markus Elfring @ 2025-10-30 13:35 UTC (permalink / raw)
To: Julia Lawall, cocci; +Cc: LKML, kernel-janitors, Miaoqian Lin
>> 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;
>> }
…>> 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:
…
Would you like to acknowledge that undesirable difference displays were generated anyhow
for these test cases?
>> Would you like to reconsider implementation details accordingly?
Are we looking for corresponding software improvements?
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 13:35 ` Markus Elfring
@ 2025-10-30 13:38 ` Julia Lawall
0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2025-10-30 13:38 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci, LKML, kernel-janitors, Miaoqian Lin
[-- Attachment #1: Type: text/plain, Size: 2322 bytes --]
On Thu, 30 Oct 2025, Markus Elfring wrote:
> >> 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;
> >> }
> …>> 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:
> …
>
> Would you like to acknowledge that undesirable difference displays were generated anyhow
> for these test cases?
Sure.
>
>
> >> Would you like to reconsider implementation details accordingly?
>
> Are we looking for corresponding software improvements?
If time permits.
julia
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 12:31 ` Julia Lawall
2025-10-30 13:35 ` Markus Elfring
@ 2025-10-30 13:47 ` Dan Carpenter
2025-10-30 13:58 ` Markus Elfring
2025-10-31 6:00 ` Markus Elfring
1 sibling, 2 replies; 17+ messages in thread
From: Dan Carpenter @ 2025-10-30 13:47 UTC (permalink / raw)
To: Julia Lawall; +Cc: Markus Elfring, cocci, LKML, kernel-janitors, Miaoqian Lin
On Thu, Oct 30, 2025 at 01:31:49PM +0100, Julia Lawall wrote:
>
>
> On Thu, 30 Oct 2025, Markus Elfring wrote:
> > @@ -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);
No one will thank you for making these changes... :( Please don't do
it.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 13:47 ` Dan Carpenter
@ 2025-10-30 13:58 ` Markus Elfring
2025-10-31 6:00 ` Markus Elfring
1 sibling, 0 replies; 17+ messages in thread
From: Markus Elfring @ 2025-10-30 13:58 UTC (permalink / raw)
To: Dan Carpenter, Julia Lawall, cocci; +Cc: LKML, kernel-janitors, Miaoqian Lin
>> - target = object; memcpy(target, source, size);
+ target = memcpy(object, source, size);
> No one will thank you for making these changes... 🙁
Will any more contributors dare to try adjustments out at such source code places?
> Please don't do it.
How will change tolerance evolve further?
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-29 21:24 ` Julia Lawall
2025-10-30 9:33 ` Markus Elfring
2025-10-30 12:26 ` Markus Elfring
@ 2025-10-30 14:06 ` Markus Elfring
2025-10-30 14:14 ` Julia Lawall
2025-10-31 16:57 ` Markus Elfring
3 siblings, 1 reply; 17+ messages in thread
From: Markus Elfring @ 2025-10-30 14:06 UTC (permalink / raw)
To: Julia Lawall, cocci, kernel-janitors; +Cc: LKML, Miaoqian Lin
> 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 the chances evolve to integrate another coccicheck script for
the discussed source code transformation approach?
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 14:06 ` Markus Elfring
@ 2025-10-30 14:14 ` Julia Lawall
2025-10-30 14:22 ` Markus Elfring
0 siblings, 1 reply; 17+ messages in thread
From: Julia Lawall @ 2025-10-30 14:14 UTC (permalink / raw)
To: Markus Elfring; +Cc: cocci, kernel-janitors, LKML, Miaoqian Lin
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 the chances evolve to integrate another coccicheck script for
> the discussed source code transformation approach?
No chance, given Dan's negative feedback.
julia
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 14:14 ` Julia Lawall
@ 2025-10-30 14:22 ` Markus Elfring
0 siblings, 0 replies; 17+ messages in thread
From: Markus Elfring @ 2025-10-30 14:22 UTC (permalink / raw)
To: Julia Lawall, cocci, kernel-janitors; +Cc: LKML, Miaoqian Lin
> No chance, given Dan's negative feedback.
Will any additional arguments become more convincing for change possibilities?
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-30 13:47 ` Dan Carpenter
2025-10-30 13:58 ` Markus Elfring
@ 2025-10-31 6:00 ` Markus Elfring
1 sibling, 0 replies; 17+ messages in thread
From: Markus Elfring @ 2025-10-31 6:00 UTC (permalink / raw)
To: Dan Carpenter, Julia Lawall, cocci, kernel-janitors; +Cc: LKML, Miaoqian Lin
> No one will thank you for making these changes... :( Please don't do it.
I am curious if further developers would dare to try another source code search pattern out.
@display@
expression destination, size, source, target;
@@
*target = memcpy(destination, source, size);
I would like to point out that return values from memcpy() calls are assigned
to variables in 16 source files of the software “Linux next-20251030”.
Under which circumstances can development interests grow to reduce “unused”
return values also for this kind of function?
https://wiki.sei.cmu.edu/confluence/display/c/MSC13-C.+Detect+and+remove+unused+values
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?
2025-10-29 21:24 ` Julia Lawall
` (2 preceding siblings ...)
2025-10-30 14:06 ` Markus Elfring
@ 2025-10-31 16:57 ` Markus Elfring
3 siblings, 0 replies; 17+ messages in thread
From: Markus Elfring @ 2025-10-31 16:57 UTC (permalink / raw)
To: Julia Lawall, cocci
> If you have a concern, you have to say what it is.
The initial search pattern might be too simple so far.
Thus I became interested in further software extensions also according to
the discussed source code transformation approach.
Can it be determined anyhow (by the means of the semantic patch language)
that the variable from the assignment statement would not be used any more
after the adjustment within the affected scope?
Regards,
Markus
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2025-10-31 16:57 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29 19:56 [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL? Markus Elfring
2025-10-29 21:24 ` 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
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
2025-10-31 16:57 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox