mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
rxrpc: abstract away knowledge of IDR internals
Add idr_get_cursor() / idr_set_cursor() APIs, and remove the reference to IDR_SIZE. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox <[email protected]> Reviewed-by: David Howells <[email protected]> Tested-by: Kirill A. Shutemov <[email protected]> Cc: Konstantin Khlebnikov <[email protected]> Cc: Ross Zwisler <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
37f4915fef
commit
444306129a
3 changed files with 34 additions and 7 deletions
|
|
@ -762,16 +762,17 @@ static const struct net_proto_family rxrpc_family_ops = {
|
|||
static int __init af_rxrpc_init(void)
|
||||
{
|
||||
int ret = -1;
|
||||
unsigned int tmp;
|
||||
|
||||
BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > FIELD_SIZEOF(struct sk_buff, cb));
|
||||
|
||||
get_random_bytes(&rxrpc_epoch, sizeof(rxrpc_epoch));
|
||||
rxrpc_epoch |= RXRPC_RANDOM_EPOCH;
|
||||
get_random_bytes(&rxrpc_client_conn_ids.cur,
|
||||
sizeof(rxrpc_client_conn_ids.cur));
|
||||
rxrpc_client_conn_ids.cur &= 0x3fffffff;
|
||||
if (rxrpc_client_conn_ids.cur == 0)
|
||||
rxrpc_client_conn_ids.cur = 1;
|
||||
get_random_bytes(&tmp, sizeof(tmp));
|
||||
tmp &= 0x3fffffff;
|
||||
if (tmp == 0)
|
||||
tmp = 1;
|
||||
idr_set_cursor(&rxrpc_client_conn_ids, tmp);
|
||||
|
||||
ret = -ENOMEM;
|
||||
rxrpc_call_jar = kmem_cache_create(
|
||||
|
|
|
|||
|
|
@ -263,12 +263,12 @@ static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn)
|
|||
* times the maximum number of client conns away from the current
|
||||
* allocation point to try and keep the IDs concentrated.
|
||||
*/
|
||||
id_cursor = READ_ONCE(rxrpc_client_conn_ids.cur);
|
||||
id_cursor = idr_get_cursor(&rxrpc_client_conn_ids);
|
||||
id = conn->proto.cid >> RXRPC_CIDSHIFT;
|
||||
distance = id - id_cursor;
|
||||
if (distance < 0)
|
||||
distance = -distance;
|
||||
limit = round_up(rxrpc_max_client_connections, IDR_SIZE) * 4;
|
||||
limit = max(rxrpc_max_client_connections * 4, 1024U);
|
||||
if (distance > limit)
|
||||
goto mark_dont_reuse;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue