linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb.c: remove dead store in demote_size_show()
@ 2021-10-03 11:41 Nghia Le
  2021-10-03 13:54 ` Matthew Wilcox
  0 siblings, 1 reply; 5+ messages in thread
From: Nghia Le @ 2021-10-03 11:41 UTC (permalink / raw)
  To: mike.kravetz, akpm, nathan, ndesaulniers
  Cc: Nghia Le, linux-mm, linux-kernel, llvm, lukas.bulwahn, kernel-janitors

The command "make clang-analyzer" detected a dead store.

Remove demote_size and corresponding assignment in function
demote_size_show() to fix dead store, as demote_size is never read.

Signed-off-by: Nghia Le <nghialm78@gmail.com>
---
 mm/hugetlb.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 993efa70bce4..ef00e6ad0f6a 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3706,11 +3706,9 @@ static ssize_t demote_size_show(struct kobject *kobj,
 					struct kobj_attribute *attr, char *buf)
 {
 	struct hstate *h;
-	unsigned long demote_size;
 	int nid;
 
 	h = kobj_to_hstate(kobj, &nid);
-	demote_size = h->demote_order;
 
 	return sysfs_emit(buf, "%lukB\n",
 			(unsigned long)(PAGE_SIZE << h->demote_order) / SZ_1K);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/hugetlb.c: remove dead store in demote_size_show()
  2021-10-03 11:41 [PATCH] mm/hugetlb.c: remove dead store in demote_size_show() Nghia Le
@ 2021-10-03 13:54 ` Matthew Wilcox
  2021-10-04  2:36   ` Mike Kravetz
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2021-10-03 13:54 UTC (permalink / raw)
  To: Nghia Le
  Cc: mike.kravetz, akpm, nathan, ndesaulniers, linux-mm, linux-kernel,
	llvm, lukas.bulwahn, kernel-janitors

On Sun, Oct 03, 2021 at 06:41:13PM +0700, Nghia Le wrote:
>  {
>  	struct hstate *h;
> -	unsigned long demote_size;
>  	int nid;
>  
>  	h = kobj_to_hstate(kobj, &nid);
> -	demote_size = h->demote_order;
>  
>  	return sysfs_emit(buf, "%lukB\n",
>  			(unsigned long)(PAGE_SIZE << h->demote_order) / SZ_1K);

I'd suggest this function would look better written as:

	int nid;
	struct hstate *h = kobj_to_hstate(kobj, &nid);
	unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K;

	return sysfs_emit(buf, "%lukB\n", demote_size);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/hugetlb.c: remove dead store in demote_size_show()
  2021-10-03 13:54 ` Matthew Wilcox
@ 2021-10-04  2:36   ` Mike Kravetz
  2021-10-04  3:44     ` Nghia Le
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Kravetz @ 2021-10-04  2:36 UTC (permalink / raw)
  To: Matthew Wilcox, Nghia Le
  Cc: akpm, nathan, ndesaulniers, linux-mm, linux-kernel, llvm,
	lukas.bulwahn, kernel-janitors

On 10/3/21 6:54 AM, Matthew Wilcox wrote:
> On Sun, Oct 03, 2021 at 06:41:13PM +0700, Nghia Le wrote:
>>  {
>>  	struct hstate *h;
>> -	unsigned long demote_size;
>>  	int nid;
>>  
>>  	h = kobj_to_hstate(kobj, &nid);
>> -	demote_size = h->demote_order;
>>  
>>  	return sysfs_emit(buf, "%lukB\n",
>>  			(unsigned long)(PAGE_SIZE << h->demote_order) / SZ_1K);
> 
> I'd suggest this function would look better written as:
> 
> 	int nid;
> 	struct hstate *h = kobj_to_hstate(kobj, &nid);
> 	unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K;
> 
> 	return sysfs_emit(buf, "%lukB\n", demote_size);
> 

Thank you Nghia Le for spotting this, and thank you Matthew for the
suggestion.

This is still just in Andrew's tree and subject to modification before
the next merge window.  I am still expecting additional comments on the
series.

If another version of the series is needed, I will include Matthew's
suggestion.   If not, I will ask Andrew how he would prefer to fold in
the changes.
-- 
Mike Kravetz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/hugetlb.c: remove dead store in demote_size_show()
  2021-10-04  2:36   ` Mike Kravetz
@ 2021-10-04  3:44     ` Nghia Le
  2021-10-04 22:46       ` Mike Kravetz
  0 siblings, 1 reply; 5+ messages in thread
From: Nghia Le @ 2021-10-04  3:44 UTC (permalink / raw)
  To: Mike Kravetz
  Cc: Matthew Wilcox, akpm, nathan, ndesaulniers, linux-mm,
	linux-kernel, llvm, lukas.bulwahn, kernel-janitors

On Sun, Oct 03, 2021 at 07:36:54PM -0700, Mike Kravetz wrote:
> On 10/3/21 6:54 AM, Matthew Wilcox wrote:
> > On Sun, Oct 03, 2021 at 06:41:13PM +0700, Nghia Le wrote:
> >>  {
> >>  	struct hstate *h;
> >> -	unsigned long demote_size;
> >>  	int nid;
> >>  
> >>  	h = kobj_to_hstate(kobj, &nid);
> >> -	demote_size = h->demote_order;
> >>  
> >>  	return sysfs_emit(buf, "%lukB\n",
> >>  			(unsigned long)(PAGE_SIZE << h->demote_order) / SZ_1K);
> > 
> > I'd suggest this function would look better written as:
> > 
> > 	int nid;
> > 	struct hstate *h = kobj_to_hstate(kobj, &nid);
> > 	unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K;
> > 
> > 	return sysfs_emit(buf, "%lukB\n", demote_size);
> >
Thanks Matthew for the clean code.
> 
> Thank you Nghia Le for spotting this, and thank you Matthew for the
> suggestion.
> 
> This is still just in Andrew's tree and subject to modification before
> the next merge window.  I am still expecting additional comments on the
> series.
> 
> If another version of the series is needed, I will include Matthew's
> suggestion.   If not, I will ask Andrew how he would prefer to fold in
> the changes.
> -- 
> Mike Kravetz
Thanks Mike, so we will wait further comments from Andrew and others.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/hugetlb.c: remove dead store in demote_size_show()
  2021-10-04  3:44     ` Nghia Le
@ 2021-10-04 22:46       ` Mike Kravetz
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Kravetz @ 2021-10-04 22:46 UTC (permalink / raw)
  To: Nghia Le
  Cc: Matthew Wilcox, akpm, nathan, ndesaulniers, linux-mm,
	linux-kernel, llvm, lukas.bulwahn, kernel-janitors

On 10/3/21 8:44 PM, Nghia Le wrote:
> On Sun, Oct 03, 2021 at 07:36:54PM -0700, Mike Kravetz wrote:
>> On 10/3/21 6:54 AM, Matthew Wilcox wrote:
>>> On Sun, Oct 03, 2021 at 06:41:13PM +0700, Nghia Le wrote:
>>>>  {
>>>>  	struct hstate *h;
>>>> -	unsigned long demote_size;
>>>>  	int nid;
>>>>  
>>>>  	h = kobj_to_hstate(kobj, &nid);
>>>> -	demote_size = h->demote_order;
>>>>  
>>>>  	return sysfs_emit(buf, "%lukB\n",
>>>>  			(unsigned long)(PAGE_SIZE << h->demote_order) / SZ_1K);
>>>
>>> I'd suggest this function would look better written as:
>>>
>>> 	int nid;
>>> 	struct hstate *h = kobj_to_hstate(kobj, &nid);
>>> 	unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K;
>>>
>>> 	return sysfs_emit(buf, "%lukB\n", demote_size);
>>>
> Thanks Matthew for the clean code.
>>
>> Thank you Nghia Le for spotting this, and thank you Matthew for the
>> suggestion.
>>
>> This is still just in Andrew's tree and subject to modification before
>> the next merge window.  I am still expecting additional comments on the
>> series.
>>
>> If another version of the series is needed, I will include Matthew's
>> suggestion.   If not, I will ask Andrew how he would prefer to fold in
>> the changes.
>> -- 
>> Mike Kravetz
> Thanks Mike, so we will wait further comments from Andrew and others.

Yes, I received suggestions for other improvements to the patch which
contains this code.  I will be putting together another version of the
series with at least these changes.

Thanks,
-- 
Mike Kravetz

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-04 22:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-03 11:41 [PATCH] mm/hugetlb.c: remove dead store in demote_size_show() Nghia Le
2021-10-03 13:54 ` Matthew Wilcox
2021-10-04  2:36   ` Mike Kravetz
2021-10-04  3:44     ` Nghia Le
2021-10-04 22:46       ` Mike Kravetz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).