Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c19c4b9c authored by Ralf Baechle's avatar Ralf Baechle Committed by David S. Miller
Browse files

[AX.25]: Optimize AX.25 socket list lock



Right now all uses of the ax25_list_lock lock are _bh locks but knowing
some code is only ever getting invoked from _bh context we can better.

Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent da952315
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -145,7 +145,7 @@ struct sock *ax25_find_listener(ax25_address *addr, int digi,
	ax25_cb *s;
	ax25_cb *s;
	struct hlist_node *node;
	struct hlist_node *node;


	spin_lock_bh(&ax25_list_lock);
	spin_lock(&ax25_list_lock);
	ax25_for_each(s, node, &ax25_list) {
	ax25_for_each(s, node, &ax25_list) {
		if ((s->iamdigi && !digi) || (!s->iamdigi && digi))
		if ((s->iamdigi && !digi) || (!s->iamdigi && digi))
			continue;
			continue;
@@ -154,12 +154,12 @@ struct sock *ax25_find_listener(ax25_address *addr, int digi,
			/* If device is null we match any device */
			/* If device is null we match any device */
			if (s->ax25_dev == NULL || s->ax25_dev->dev == dev) {
			if (s->ax25_dev == NULL || s->ax25_dev->dev == dev) {
				sock_hold(s->sk);
				sock_hold(s->sk);
				spin_unlock_bh(&ax25_list_lock);
				spin_unlock(&ax25_list_lock);
				return s->sk;
				return s->sk;
			}
			}
		}
		}
	}
	}
	spin_unlock_bh(&ax25_list_lock);
	spin_unlock(&ax25_list_lock);


	return NULL;
	return NULL;
}
}
@@ -174,7 +174,7 @@ struct sock *ax25_get_socket(ax25_address *my_addr, ax25_address *dest_addr,
	ax25_cb *s;
	ax25_cb *s;
	struct hlist_node *node;
	struct hlist_node *node;


	spin_lock_bh(&ax25_list_lock);
	spin_lock(&ax25_list_lock);
	ax25_for_each(s, node, &ax25_list) {
	ax25_for_each(s, node, &ax25_list) {
		if (s->sk && !ax25cmp(&s->source_addr, my_addr) &&
		if (s->sk && !ax25cmp(&s->source_addr, my_addr) &&
		    !ax25cmp(&s->dest_addr, dest_addr) &&
		    !ax25cmp(&s->dest_addr, dest_addr) &&
@@ -185,7 +185,7 @@ struct sock *ax25_get_socket(ax25_address *my_addr, ax25_address *dest_addr,
		}
		}
	}
	}


	spin_unlock_bh(&ax25_list_lock);
	spin_unlock(&ax25_list_lock);


	return sk;
	return sk;
}
}
@@ -235,7 +235,7 @@ void ax25_send_to_raw(ax25_address *addr, struct sk_buff *skb, int proto)
	struct sk_buff *copy;
	struct sk_buff *copy;
	struct hlist_node *node;
	struct hlist_node *node;


	spin_lock_bh(&ax25_list_lock);
	spin_lock(&ax25_list_lock);
	ax25_for_each(s, node, &ax25_list) {
	ax25_for_each(s, node, &ax25_list) {
		if (s->sk != NULL && ax25cmp(&s->source_addr, addr) == 0 &&
		if (s->sk != NULL && ax25cmp(&s->source_addr, addr) == 0 &&
		    s->sk->sk_type == SOCK_RAW &&
		    s->sk->sk_type == SOCK_RAW &&
@@ -248,7 +248,7 @@ void ax25_send_to_raw(ax25_address *addr, struct sk_buff *skb, int proto)
				kfree_skb(copy);
				kfree_skb(copy);
		}
		}
	}
	}
	spin_unlock_bh(&ax25_list_lock);
	spin_unlock(&ax25_list_lock);
}
}


/*
/*
+4 −4
Original line number Original line Diff line number Diff line
@@ -80,7 +80,7 @@ void ax25_ds_enquiry_response(ax25_cb *ax25)
	ax25_start_t3timer(ax25);
	ax25_start_t3timer(ax25);
	ax25_ds_set_timer(ax25->ax25_dev);
	ax25_ds_set_timer(ax25->ax25_dev);


	spin_lock_bh(&ax25_list_lock);
	spin_lock(&ax25_list_lock);
	ax25_for_each(ax25o, node, &ax25_list) {
	ax25_for_each(ax25o, node, &ax25_list) {
		if (ax25o == ax25)
		if (ax25o == ax25)
			continue;
			continue;
@@ -106,7 +106,7 @@ void ax25_ds_enquiry_response(ax25_cb *ax25)
		if (ax25o->state != AX25_STATE_0)
		if (ax25o->state != AX25_STATE_0)
			ax25_start_t3timer(ax25o);
			ax25_start_t3timer(ax25o);
	}
	}
	spin_unlock_bh(&ax25_list_lock);
	spin_unlock(&ax25_list_lock);
}
}


void ax25_ds_establish_data_link(ax25_cb *ax25)
void ax25_ds_establish_data_link(ax25_cb *ax25)
@@ -162,13 +162,13 @@ static int ax25_check_dama_slave(ax25_dev *ax25_dev)
	int res = 0;
	int res = 0;
	struct hlist_node *node;
	struct hlist_node *node;


	spin_lock_bh(&ax25_list_lock);
	spin_lock(&ax25_list_lock);
	ax25_for_each(ax25, node, &ax25_list)
	ax25_for_each(ax25, node, &ax25_list)
		if (ax25->ax25_dev == ax25_dev && (ax25->condition & AX25_COND_DAMA_MODE) && ax25->state > AX25_STATE_1) {
		if (ax25->ax25_dev == ax25_dev && (ax25->condition & AX25_COND_DAMA_MODE) && ax25->state > AX25_STATE_1) {
			res = 1;
			res = 1;
			break;
			break;
		}
		}
	spin_unlock_bh(&ax25_list_lock);
	spin_unlock(&ax25_list_lock);


	return res;
	return res;
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -85,7 +85,7 @@ static void ax25_ds_timeout(unsigned long arg)
		return;
		return;
	}
	}


	spin_lock_bh(&ax25_list_lock);
	spin_lock(&ax25_list_lock);
	ax25_for_each(ax25, node, &ax25_list) {
	ax25_for_each(ax25, node, &ax25_list) {
		if (ax25->ax25_dev != ax25_dev || !(ax25->condition & AX25_COND_DAMA_MODE))
		if (ax25->ax25_dev != ax25_dev || !(ax25->condition & AX25_COND_DAMA_MODE))
			continue;
			continue;
@@ -93,7 +93,7 @@ static void ax25_ds_timeout(unsigned long arg)
		ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
		ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
		ax25_disconnect(ax25, ETIMEDOUT);
		ax25_disconnect(ax25, ETIMEDOUT);
	}
	}
	spin_unlock_bh(&ax25_list_lock);
	spin_unlock(&ax25_list_lock);


	ax25_dev_dama_off(ax25_dev);
	ax25_dev_dama_off(ax25_dev);
}
}