Skip to contentSkip to conversation

drivers: hv: remove redundant assignment to pointer primary_channel

PATCH In review Colin King 5 participants 10 messages Apr 14, 2020 – Apr 16, 2020

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drivers: hv: remove redundant assignment to pointer primary_channel

From: Colin Ian King <[email protected]>

The pointer primary_channel is being assigned with a value that is never, The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/hv/channel_mgmt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hv/channel_mgmt.c +0 -2
index ffd7fffa5f83..f7bbb8dc4b0f 100644
@@ -425,8 +425,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 
 	if (channel->primary_channel = NULL) {
 		list_del(&channel->listentry);
-
-		primary_channel = channel;
 	} else {
 		primary_channel = channel->primary_channel;
 		spin_lock_irqsave(&primary_channel->lock, flags);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer primary_channel is being assigned with a value that is never,

never -> never used :)

Quoted 25 lines

The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/hv/channel_mgmt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hv/channel_mgmt.c +0 -3
index ffd7fffa5f83..f7bbb8dc4b0f 100644
@@ -425,8 +425,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 
 	if (channel->primary_channel = NULL) {
 		list_del(&channel->listentry);
-
-		primary_channel = channel;
 	} else {
 		primary_channel = channel->primary_channel;
 		spin_lock_irqsave(&primary_channel->lock, flags);
--

2.25.1

#2 lore raw
In reply to Colin King
Quoted 16 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer primary_channel is being assigned with a value that is never, The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/hv/channel_mgmt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hv/channel_mgmt.c +0 -0
index ffd7fffa5f83..f7bbb8dc4b0f 100644

drivers/hv/channel_mgmt.c void hv_process_channel_removal(struct vmbus_channel *channel) · line 430

Quoted 8 lines
drivers/hv/channel_mgmt.c +0 -2
@@ -425,8 +425,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 
 	if (channel->primary_channel = NULL) {
 		list_del(&channel->listentry);
-
-		primary_channel = channel;
 	} else {
 		primary_channel = channel->primary_channel;
 		spin_lock_irqsave(&primary_channel->lock, flags);

If I'm looking at the right source (5.7-rc1) it *is* beeing used:

	if (channel->primary_channel = NULL) {
		list_del(&channel->listentry);

		primary_channel = channel;
	} else {
		primary_channel = channel->primary_channel;
		spin_lock_irqsave(&primary_channel->lock, flags);
		list_del(&channel->sc_list);
		spin_unlock_irqrestore(&primary_channel->lock, flags);
	}

	/*
	 * We need to free the bit for init_vp_index() to work in the case
	 * of sub-channel, when we reload drivers like hv_netvsc.
	 */
	if (channel->affinity_policy = HV_LOCALIZED)
		cpumask_clear_cpu(channel->target_cpu,
				  &primary_channel->alloced_cpus_in_node);
                                   ^^^^^ HERE ^^^^^
Signature · 1 line
Vitaly
author Reviewed-by Michael Kelley
#3 lore raw
Quoted 40 lines · Vitaly Kuznetsov
Quoted 16 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer primary_channel is being assigned with a value that is never, The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/hv/channel_mgmt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hv/channel_mgmt.c +0 -0
index ffd7fffa5f83..f7bbb8dc4b0f 100644

drivers/hv/channel_mgmt.c void hv_process_channel_removal(struct vmbus_channel *channel) · line 430

Quoted 8 lines
drivers/hv/channel_mgmt.c +0 -2
@@ -425,8 +425,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 
 	if (channel->primary_channel = NULL) {
 		list_del(&channel->listentry);
-
-		primary_channel = channel;
 	} else {
 		primary_channel = channel->primary_channel;
 		spin_lock_irqsave(&primary_channel->lock, flags);

If I'm looking at the right source (5.7-rc1) it *is* beeing used:

	if (channel->primary_channel = NULL) {
		list_del(&channel->listentry);

		primary_channel = channel;
	} else {
		primary_channel = channel->primary_channel;
		spin_lock_irqsave(&primary_channel->lock, flags);
		list_del(&channel->sc_list);
		spin_unlock_irqrestore(&primary_channel->lock, flags);
	}
Quoted 9 lines
	/*
	 * We need to free the bit for init_vp_index() to work in the case
	 * of sub-channel, when we reload drivers like hv_netvsc.
	 */
	if (channel->affinity_policy = HV_LOCALIZED)
		cpumask_clear_cpu(channel->target_cpu,
				  &primary_channel->alloced_cpus_in_node);
                                   ^^^^^ HERE ^^^^^

I was basing my change on linux-next that has removed a hunk of code:

commit bcefa400900739310e8ef0cb34cbe029c404455c

Author: Andrea Parri (Microsoft) <[email protected]>
Date:   Mon Apr 6 02:15:11 2020 +0200

Drivers: hv: vmbus: Remove the unused HV_LOCALIZED channel affinity
logic

The logic is unused since commit 509879bdb30b8 ("Drivers: hv: Introduce a policy for controlling channel affinity").

This logic assumes that a channel target_cpu doesn't change during the lifetime of a channel, but this assumption is incompatible with the new functionality that allows changing the vCPU a channel will interrupt.

Link:
https://lore.kernel.org/r/[email protected]

drivers/hv/channel_mgmt.c +0 -0
index 7fb6eb647f14..476592b0bc00 100644
@@ -433,14 +433,6 @@ void hv_process_channel_removal(struct

vmbus_channel *channel)

                spin_unlock_irqrestore(&primary_channel->lock, flags);
        }

- /*

-        * We need to free the bit for init_vp_index() to work in the case
-        * of sub-channel, when we reload drivers like hv_netvsc.
-        */

- if (channel->affinity_policy = HV_LOCALIZED)
- cpumask_clear_cpu(channel->target_cpu,
- &primary_channel->alloced_cpus_in_node);
-

#4 lore raw
Quoted 51 lines · Colin Ian King
Quoted 40 lines · Vitaly Kuznetsov
Quoted 16 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer primary_channel is being assigned with a value that is never, The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/hv/channel_mgmt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hv/channel_mgmt.c +0 -0
index ffd7fffa5f83..f7bbb8dc4b0f 100644

drivers/hv/channel_mgmt.c void hv_process_channel_removal(struct vmbus_channel *channel) · line 430

Quoted 8 lines
drivers/hv/channel_mgmt.c +0 -2
@@ -425,8 +425,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 
 	if (channel->primary_channel = NULL) {
 		list_del(&channel->listentry);
-
-		primary_channel = channel;
 	} else {
 		primary_channel = channel->primary_channel;
 		spin_lock_irqsave(&primary_channel->lock, flags);

If I'm looking at the right source (5.7-rc1) it *is* beeing used:

	if (channel->primary_channel = NULL) {
		list_del(&channel->listentry);

		primary_channel = channel;
	} else {
		primary_channel = channel->primary_channel;
		spin_lock_irqsave(&primary_channel->lock, flags);
		list_del(&channel->sc_list);
		spin_unlock_irqrestore(&primary_channel->lock, flags);
	}
Quoted 9 lines
	/*
	 * We need to free the bit for init_vp_index() to work in the case
	 * of sub-channel, when we reload drivers like hv_netvsc.
	 */
	if (channel->affinity_policy = HV_LOCALIZED)
		cpumask_clear_cpu(channel->target_cpu,
				  &primary_channel->alloced_cpus_in_node);
                                   ^^^^^ HERE ^^^^^
Quoted 9 lines

I was basing my change on linux-next that has removed a hunk of code:

commit bcefa400900739310e8ef0cb34cbe029c404455c

Author: Andrea Parri (Microsoft) <[email protected]>
Date:   Mon Apr 6 02:15:11 2020 +0200

Drivers: hv: vmbus: Remove the unused HV_LOCALIZED channel affinity
logic

Ah, please add the right 'Fixes:' tag then.

Signature · 1 line
Vitaly
maintainer
#5 lore raw
Quoted 59 lines · Vitaly Kuznetsov
Quoted 57 lines · Colin Ian King
Quoted 40 lines · Vitaly Kuznetsov
Quoted 16 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer primary_channel is being assigned with a value that is never, The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/hv/channel_mgmt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hv/channel_mgmt.c +0 -0
index ffd7fffa5f83..f7bbb8dc4b0f 100644

drivers/hv/channel_mgmt.c void hv_process_channel_removal(struct vmbus_channel *channel) · line 430

Quoted 8 lines
drivers/hv/channel_mgmt.c +0 -2
@@ -425,8 +425,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 
 	if (channel->primary_channel = NULL) {
 		list_del(&channel->listentry);
-
-		primary_channel = channel;
 	} else {
 		primary_channel = channel->primary_channel;
 		spin_lock_irqsave(&primary_channel->lock, flags);

If I'm looking at the right source (5.7-rc1) it *is* beeing used:

	if (channel->primary_channel = NULL) {
		list_del(&channel->listentry);

		primary_channel = channel;
	} else {
		primary_channel = channel->primary_channel;
		spin_lock_irqsave(&primary_channel->lock, flags);
		list_del(&channel->sc_list);
		spin_unlock_irqrestore(&primary_channel->lock, flags);
	}
Quoted 9 lines
	/*
	 * We need to free the bit for init_vp_index() to work in the case
	 * of sub-channel, when we reload drivers like hv_netvsc.
	 */
	if (channel->affinity_policy = HV_LOCALIZED)
		cpumask_clear_cpu(channel->target_cpu,
				  &primary_channel->alloced_cpus_in_node);
                                   ^^^^^ HERE ^^^^^

I was basing my change on linux-next that has removed a hunk of code:

commit bcefa400900739310e8ef0cb34cbe029c404455c

Author: Andrea Parri (Microsoft) <[email protected]>
Date:   Mon Apr 6 02:15:11 2020 +0200
Quoted 5 lines
Quoted 3 lines

Drivers: hv: vmbus: Remove the unused HV_LOCALIZED channel affinity
logic

Ah, please add the right 'Fixes:' tag then.

I don't think the Fixes tag is particularly useful in this instance. Andrea's commit is not yet in Linus' tree. If I rebase hyper-next over the next 2.5 months the tag is going to have a stale commit hash in it.

Wei.

Quoted 4 lines
Signature · 2 lines
-- 
Vitaly
#6 lore raw

We have this discussion over and over. I always say it helps to have the commit mentioned in the commit message but it's not a Fixes tag. So I think that the commit message should say something like "commit 1234234 ("blah blah") removed some code so this variable isn't used any more". I think it helps the review process. But then if we mention the commit everyone says to use the Fixes tag.

It turns out if you leave out the commit entirely then people still complain but a lot less frequently. It shouldn't work that way but reviewers are illogical.

regards,
dan carpenter

#7 lore raw
Quoted 10 lines · Dan Carpenter

We have this discussion over and over. I always say it helps to have the commit mentioned in the commit message but it's not a Fixes tag. So I think that the commit message should say something like "commit 1234234 ("blah blah") removed some code so this variable isn't used any more". I think it helps the review process. But then if we mention the commit everyone says to use the Fixes tag.

It turns out if you leave out the commit entirely then people still complain but a lot less frequently. It shouldn't work that way but reviewers are illogical.

Yep, to my knowledge the policy for this kind of commit is not described in any documentation, so it's ambiguous. Either way, one can't win without it being properly codified.

Colin

Quoted 4 lines

regards,
dan carpenter

maintainer
#8 lore raw
In reply to Colin King
Quoted 7 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer primary_channel is being assigned with a value that is never, The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

Thanks.

Now that the only user of primary_channel is within the else branch, we can go one step further to move the definition of primary_channel there.

I can make the adjustment while committing this patch, as well as updating the commit message.

Wei.

Quoted 20 lines
---
 drivers/hv/channel_mgmt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hv/channel_mgmt.c +0 -2
index ffd7fffa5f83..f7bbb8dc4b0f 100644
@@ -425,8 +425,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 
 	if (channel->primary_channel = NULL) {
 		list_del(&channel->listentry);
-
-		primary_channel = channel;
 	} else {
 		primary_channel = channel->primary_channel;
 		spin_lock_irqsave(&primary_channel->lock, flags);
Signature · 1 line
2.25.1
#9 lore raw
Quoted 11 lines · Wei Liu
Quoted 7 lines · Colin King

From: Colin Ian King <[email protected]>

The pointer primary_channel is being assigned with a value that is never, The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

Thanks.

Quoted 7 lines

Now that the only user of primary_channel is within the else branch, we can go one step further to move the definition of primary_channel there.

I can make the adjustment while committing this patch, as well as updating the commit message.

Wei.

Thanks Wei,

Colin

Quoted 21 lines
Quoted 21 lines
---
 drivers/hv/channel_mgmt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/hv/channel_mgmt.c +0 -2
index ffd7fffa5f83..f7bbb8dc4b0f 100644
@@ -425,8 +425,6 @@ void hv_process_channel_removal(struct vmbus_channel *channel)
 
 	if (channel->primary_channel = NULL) {
 		list_del(&channel->listentry);
-
-		primary_channel = channel;
 	} else {
 		primary_channel = channel->primary_channel;
 		spin_lock_irqsave(&primary_channel->lock, flags);
Signature · 1 line
2.25.1