From nobody Sun Feb 8 12:14:33 2026 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:7824:0:0:0:0:0 with SMTP id p36csp427593jac; Fri, 15 Oct 2021 08:40:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYqw4zpO+5ziz9DtPryMEcbgQbbC7/4f6uYI9/1sDi2bhg9Y1D+S6HbSjauDCI6ct0pdEL X-Received: by 2002:a17:90b:3b88:: with SMTP id pc8mr13872391pjb.93.1634312450666; Fri, 15 Oct 2021 08:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634312450; cv=none; d=google.com; s=arc-20160816; b=t59CCSMXs2qI3ao30+sMsV/uactW8F5P1RW0penaKrfKIIVezLGNo8Ke36lFRoJ6fE Z2xj8n1yCa5KxWOQmmHhKV4J5CLb6APDcQIHOoFwNqft4sXYy4eeIeMLYkknGxM79TQk 6ywMA2elN8PCm6f1VgdZm8WsshXv/RZeNNN0c+Ov7dIKaV4/7BcV0qGsz2yNiP8tiR+X fmCtXpLv91VqaWLIkZV3Ooa6FI6PpD6bLZCuUiJPwH8iRQn/nuZi6Cu5dSMni8Quy5q7 7xm0toa9EFgoU/GjB1/gW5dTDpy7ts9NMbcjuPe2t8zMceDDcCdd7Trt/YATuqNw7O0h PO8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=9CfqUPu7O1w8W4v6WD5zHDCxWC8uPzyP6pFLYQwAak8=; b=wBFQHI3+vctT6wuA+21rNaZ4ymx/C1ozJ/oymT2OwwsRH268wwpgF1yTtWwvRN1bBz iEQ9pdC7cVXNgqgArWfmdnEYH0saT49AItGc7gwK6O4wL3NwFQOdovo3QlWgzROsuvWz 9AKXJAxEcdczSFMZXLHberkQOZMz8Yo1NgSOCZc0H/x8zlLLgNdd1J2Z/fBoPOT8C2Jo kEXnU6yt0/hrgTcqMi5owsV7b9WzKdJW6NTjO+YOIXU080uJobaoIN1iEuFFck9P0ez1 Rf4D6fjkj4OizZqg4u4C3QJbWQLu606M7/u4y+qA8s6kE4k6OEbDHqTKNyDvOU9l8mqk g1pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B8TkBWx+; spf=pass (google.com: domain of mptcp+bounces-2170-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) smtp.mailfrom="mptcp+bounces-2170-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ewr.edge.kernel.org (ewr.edge.kernel.org. [147.75.197.195]) by mx.google.com with ESMTPS id p14si5634773pll.89.2021.10.15.08.40.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Oct 2021 08:40:50 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-2170-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) client-ip=147.75.197.195; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B8TkBWx+; spf=pass (google.com: domain of mptcp+bounces-2170-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) smtp.mailfrom="mptcp+bounces-2170-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ewr.edge.kernel.org (Postfix) with ESMTPS id CCA761C0F83 for ; Fri, 15 Oct 2021 15:40:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A522E2C85; Fri, 15 Oct 2021 15:40:45 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C4CF29CA for ; Fri, 15 Oct 2021 15:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634312443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9CfqUPu7O1w8W4v6WD5zHDCxWC8uPzyP6pFLYQwAak8=; b=B8TkBWx+B6a/p09tdxU7dFI4INqBTUpzTFGwN5fLChCWiWV1E0lWHSGLXw76VOpetQ9bQp v+KpkrgAFyZ7COHMDTkPni8Lw1HzlOPsG52knoSD8ibrKLqsIwoYOV2jjaOsbuyv+lZRzD LL7HgSKKW0B3bFsEZi4J1ffaW+TE88M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-540-zxh6IL-WOMm6BXkoqP9hkQ-1; Fri, 15 Oct 2021 11:40:41 -0400 X-MC-Unique: zxh6IL-WOMm6BXkoqP9hkQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A25EF91271 for ; Fri, 15 Oct 2021 15:40:40 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.192.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A4A9ADD7 for ; Fri, 15 Oct 2021 15:40:39 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next v2 2/3] net: introduce sk_forward_alloc_get() Date: Fri, 15 Oct 2021 17:39:38 +0200 Message-Id: <944348e29bd564a3e45d7ab6683c4e64ef48aec1.1634312286.git.pabeni@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A later patch will change the mptcp memory accounting schema in such a way that MPTCP sockets will encode total amount of forward allocated memory in two separate fields (one for tx and one for rx). MPTCP sockets will use their own helper to provide the accurate amount of fwd alloced memory. To allow the above, this patch adds a new, optional, sk method to fetch the fwd memory, wrap the call in a new helper and use it where apprioriate. Signed-off-by: Paolo Abeni Acked-by: Mat Martineau --- This schema was suggested long time ago by Eric in a completely different context: https://marc.info/?l=3Dlinux-netdev&m=3D147516056204838&w=3D2 I'm unsure if that is still applicable/valid. --- include/net/sock.h | 11 +++++++++++ net/ipv4/af_inet.c | 2 +- net/ipv4/inet_diag.c | 2 +- net/sched/em_meta.c | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index 9c5d0502090f..86ea60df6e84 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1205,6 +1205,8 @@ struct proto { unsigned int inuse_idx; #endif =20 + int (*forward_alloc_get)(const struct sock *sk); + bool (*stream_memory_free)(const struct sock *sk, int wake); bool (*stream_memory_read)(const struct sock *sk); /* Memory pressure */ @@ -1212,6 +1214,7 @@ struct proto { void (*leave_memory_pressure)(struct sock *sk); atomic_long_t *memory_allocated; /* Current allocated memory. */ struct percpu_counter *sockets_allocated; /* Current number of sockets. */ + /* * Pressure flag: try to collapse. * Technical note: it is used by multiple contexts non atomically. @@ -1289,6 +1292,14 @@ static inline void sk_refcnt_debug_release(const str= uct sock *sk) =20 INDIRECT_CALLABLE_DECLARE(bool tcp_stream_memory_free(const struct sock *s= k, int wake)); =20 +static inline int sk_forward_alloc_get(const struct sock *sk) +{ + if (!sk->sk_prot->forward_alloc_get) + return sk->sk_forward_alloc; + + return sk->sk_prot->forward_alloc_get(sk); +} + static inline bool __sk_stream_memory_free(const struct sock *sk, int wake) { if (READ_ONCE(sk->sk_wmem_queued) >=3D READ_ONCE(sk->sk_sndbuf)) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 37e69fd9246c..55f862abe811 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -150,7 +150,7 @@ void inet_sock_destruct(struct sock *sk) WARN_ON(atomic_read(&sk->sk_rmem_alloc)); WARN_ON(refcount_read(&sk->sk_wmem_alloc)); WARN_ON(sk->sk_wmem_queued); - WARN_ON(sk->sk_forward_alloc); + WARN_ON(sk_forward_alloc_get(sk)); =20 kfree(rcu_dereference_protected(inet->inet_opt, 1)); dst_release(rcu_dereference_protected(sk->sk_dst_cache, 1)); diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index ef7897226f08..c8fa6e7f7d12 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -271,7 +271,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_conn= ection_sock *icsk, struct inet_diag_meminfo minfo =3D { .idiag_rmem =3D sk_rmem_alloc_get(sk), .idiag_wmem =3D READ_ONCE(sk->sk_wmem_queued), - .idiag_fmem =3D sk->sk_forward_alloc, + .idiag_fmem =3D sk_forward_alloc_get(sk), .idiag_tmem =3D sk_wmem_alloc_get(sk), }; =20 diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index 46254968d390..0a04468b7314 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c @@ -457,7 +457,7 @@ META_COLLECTOR(int_sk_fwd_alloc) *err =3D -1; return; } - dst->value =3D sk->sk_forward_alloc; + dst->value =3D sk_forward_alloc_get(sk); } =20 META_COLLECTOR(int_sk_sndbuf) --=20 2.26.3