Skip to content

Commit

Permalink
mptcp: drop SK_RECLAIM_* macros
Browse files Browse the repository at this point in the history
After commit 4890b68 ("net: keep sk->sk_forward_alloc as small as
possible"), the MPTCP protocol is the last SK_RECLAIM_CHUNK and
SK_RECLAIM_THRESHOLD users.

Update the MPTCP reclaim schema to match the core/TCP one and drop the
mentioned macros. This additionally clean the MPTCP code a bit.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Paolo Abeni authored and davem330 committed Jul 1, 2022
1 parent 4aaa168 commit d24141f
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ static void mptcp_rmem_uncharge(struct sock *sk, int size)
reclaimable = msk->rmem_fwd_alloc - sk_unused_reserved_mem(sk);

/* see sk_mem_uncharge() for the rationale behind the following schema */
if (unlikely(reclaimable >= SK_RECLAIM_THRESHOLD))
__mptcp_rmem_reclaim(sk, SK_RECLAIM_CHUNK);
if (unlikely(reclaimable >= PAGE_SIZE))
__mptcp_rmem_reclaim(sk, reclaimable);
}

static void mptcp_rfree(struct sk_buff *skb)
Expand Down Expand Up @@ -961,25 +961,6 @@ static bool mptcp_frag_can_collapse_to(const struct mptcp_sock *msk,
df->data_seq + df->data_len == msk->write_seq;
}

static void __mptcp_mem_reclaim_partial(struct sock *sk)
{
int reclaimable = mptcp_sk(sk)->rmem_fwd_alloc - sk_unused_reserved_mem(sk);

lockdep_assert_held_once(&sk->sk_lock.slock);

if (reclaimable > (int)PAGE_SIZE)
__mptcp_rmem_reclaim(sk, reclaimable - 1);

sk_mem_reclaim(sk);
}

static void mptcp_mem_reclaim_partial(struct sock *sk)
{
mptcp_data_lock(sk);
__mptcp_mem_reclaim_partial(sk);
mptcp_data_unlock(sk);
}

static void dfrag_uncharge(struct sock *sk, int len)
{
sk_mem_uncharge(sk, len);
Expand All @@ -999,7 +980,6 @@ static void __mptcp_clean_una(struct sock *sk)
{
struct mptcp_sock *msk = mptcp_sk(sk);
struct mptcp_data_frag *dtmp, *dfrag;
bool cleaned = false;
u64 snd_una;

/* on fallback we just need to ignore snd_una, as this is really
Expand All @@ -1022,7 +1002,6 @@ static void __mptcp_clean_una(struct sock *sk)
}

dfrag_clear(sk, dfrag);
cleaned = true;
}

dfrag = mptcp_rtx_head(sk);
Expand All @@ -1044,17 +1023,13 @@ static void __mptcp_clean_una(struct sock *sk)
dfrag->already_sent -= delta;

dfrag_uncharge(sk, delta);
cleaned = true;
}

/* all retransmitted data acked, recovery completed */
if (unlikely(msk->recovery) && after64(msk->snd_una, msk->recovery_snd_nxt))
msk->recovery = false;

out:
if (cleaned && tcp_under_memory_pressure(sk))
__mptcp_mem_reclaim_partial(sk);

if (snd_una == READ_ONCE(msk->snd_nxt) &&
snd_una == READ_ONCE(msk->write_seq)) {
if (mptcp_timer_pending(sk) && !mptcp_data_fin_enabled(msk))
Expand Down Expand Up @@ -1206,12 +1181,6 @@ static struct sk_buff *mptcp_alloc_tx_skb(struct sock *sk, struct sock *ssk, boo
{
gfp_t gfp = data_lock_held ? GFP_ATOMIC : sk->sk_allocation;

if (unlikely(tcp_under_memory_pressure(sk))) {
if (data_lock_held)
__mptcp_mem_reclaim_partial(sk);
else
mptcp_mem_reclaim_partial(sk);
}
return __mptcp_alloc_tx_skb(sk, ssk, gfp);
}

Expand Down

0 comments on commit d24141f

Please sign in to comment.