Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1895594rbb; Tue, 27 Feb 2024 04:55:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXTY+34CLuVVhV/qYwbwt6/yXhR3bNLn/vESU7rKufVZgQmRbZWwKulMXEWqvwOFpumpmQ3B/nYIQH017OGt3u1lsy2uGOvDgbORxg4Tg== X-Google-Smtp-Source: AGHT+IFow8erjRPAe8wKQ81aEThlp7r97sEFJ2JzrxOO8EGM0jpBGl33zTCiv1TzDRKgMOwwFpz/ X-Received: by 2002:a05:622a:2cb:b0:42e:7a9a:f13b with SMTP id a11-20020a05622a02cb00b0042e7a9af13bmr10233542qtx.58.1709038546164; Tue, 27 Feb 2024 04:55:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709038546; cv=pass; d=google.com; s=arc-20160816; b=QySB4hofAv87TVpQ6giN3XH53HfY3lNdWuufh2L6x1QGfTg/2iwtkRdXzHjNaV3PzD ID8vYe/yGEYiArFEzWvlskorLiHtlCztazFjxewAl7M2U4ezfJ8Nnnyd4NSetdtEbR1z iuNDyYiB46jB6HIUCkFVYt2SF8S9OOlOTw0G2Vzvda2UKXxULgrkqCj5RFXQ8mLUwbbL XmruSeUvcEwNVr+d1RnBAe2ILa+ITeye9DTqipdRKQp2DAf2wtsu/Lx24yURRzZLRqhr Z+dq9+qGmugM5E7T0AAcDo827nCsyhgt6q2BOUltxg7ag92pDL+pgKNY4BEsVSIV9h3r jdRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=MLBUJ2xAHGF+c3kUR836B1kJhRUeAGnSjULsaIYn3hI=; fh=WX6ycYa8dQHKl7YETXFKmzB0Gae+DfgA20lhQWot0Xg=; b=Z0+vG5fBPZoNnuYulVca1u3mawfZbS+w730ZVWVn113mzS4a2ETEBFnjnY0m1o3siw S3iG2QCXjec4nq/vfFrSPL62LzsMNjHiafxH/Zv/TA2IwXjaQ7d1v8f0tyrn1aYz6nyW CtZ6RcMIxAkVvp9N5WCza948GIue967EzX4IBYUL/hndgSM/edPFphvef5aF6mtiQELc GkILopQIyAmnKL+cgcwd/qu7SQbVPGMaK8J0qoqITIJO0HsaG+DjBjhv3Tml96OW4z0x Wy87dkzeXyV2LtxWLz7+1QR5jrj8fchaowE1l/gULmYBM/1iP1Df0W/QkGy3mXMgnZuR AVNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ar6lGGLB; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-83268-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83268-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x26-20020ac8539a000000b0042e5f682270si7147081qtp.624.2024.02.27.04.55.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 04:55:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83268-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ar6lGGLB; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-83268-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83268-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6A6EA1C246EF for ; Tue, 27 Feb 2024 12:55:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B9CC13A886; Tue, 27 Feb 2024 12:55:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ar6lGGLB" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9600135A43 for ; Tue, 27 Feb 2024 12:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709038525; cv=none; b=J+dIawKxntnthfcD9CB5XQZ3opA5dmi5FVg1Uvnw4Syy+kDsJgzg8cLODZpXWjPNIpA/yxmjAJZUmj7O0HE7iSAQJwqFyaf3yeTwNJOXap2lvNaYExqgioD59hhlm4ZFGV9j6T4vS3+YZepKhdJvFJl1NKTmUy/y1tER4MQxejQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709038525; c=relaxed/simple; bh=KJz9hRO8fRmQUceWUmOGhb9xcb17Ny+mYe4CX9Me5cU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=HJKBQJqS3ZMTfMJVdKIVc0FUigaYTJajguE93h6q92PrPwOk9EHAn94zx50jPXd56TTCOY5ePxy7Iu2vEbI+mlxaOZkvaWZVSF08SPIBYSFhqAC5hCP8CSaJiUMLAE1Xht6C1+bP6k9KE4QWUQU7wcH2RCVhTHWyluGr4mXEDAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ar6lGGLB; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5664623c311so4910a12.1 for ; Tue, 27 Feb 2024 04:55:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709038522; x=1709643322; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MLBUJ2xAHGF+c3kUR836B1kJhRUeAGnSjULsaIYn3hI=; b=ar6lGGLB3BZJH1YySaUrWaQQTeeMFXzWJQnrfnS+Znqc6Ml3YidGSrAkmsmCaWhMxc Sxyi4V28I7T9TM0lm2WDMHriFr6DaHmIBjavhFhwVMk8SRqwFUgpgn42NiYknSRck3zZ lo8Esj8glh8+h60/xveXota/tEVY8PvbgMlQ/n1nrtEzaGvIHtXa6wmXTIeO5vH4w4aY p6LZsn/BzrUo1/lzE1fGD+Vw7zYHG/HAKolQLYPTZrUythbltLbtdfwU7itOfaSUdYyA XejrYLbw7nBrvTQu6eosxRCGa8eFiNOqt+C9ItQDBYIrdcPq7uCmQElE3WsiB52uutAP xFMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709038522; x=1709643322; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MLBUJ2xAHGF+c3kUR836B1kJhRUeAGnSjULsaIYn3hI=; b=R/Jlgd/06lRl3e1+RyGfWEg0DN7up99n8WKrFsh8v07nwOaT2R8+Dq0Wel6f14plJx YtguhyRGeTQKNnc1/PpKIVwrpXx6RSMcVlvMXlIENWgZhRvipjXeLYpMpd/THxMRRJvO Kh6/wmQk/38Y+Dv5vWMwFuB1ecteH3J1PpCTGtl2YdXnF7DsTfhOGgT6/ymAPeI87X9+ MsYiJRJXAZqMJQZkF+RXZIndYjbid2WO6Jf61awbV+iqSHEgDlbKxPd91hItJwK9UKtL t71rdtubg9HEvBNB2SYx7ErQHZtfXYXhdoTDIqfLHeU5jhs/rRgArstjEaPYJeNLMjA0 eGqw== X-Forwarded-Encrypted: i=1; AJvYcCW8as3YG7G3QrbmYi6zDYAWA7M1iqc9HtMO1CthTawEqRPehGSujVO9tn5tbn7opyzjUc76bA4s3rfX02LqnDnOP/BOcqOEzxOo+X5I X-Gm-Message-State: AOJu0Yz7+A7EHQkMHCqW5zFD1sXVCD1DaItZIH0KfSQ/51uPiuRqRjpV Oe0YXxcQg8ZaSIozAXMqO/UmKAOzS1v1JzETP/wFPpbljVM/EdwN11IwCJJ3mTl+6YXxdmWXjO7 MwyxT9qTUpmSjw7E697nCZXKxhMhMK08y7Py3 X-Received: by 2002:a50:a448:0:b0:565:abf9:1974 with SMTP id v8-20020a50a448000000b00565abf91974mr191729edb.2.1709038521727; Tue, 27 Feb 2024 04:55:21 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240227062833.7404-1-shijie@os.amperecomputing.com> In-Reply-To: <20240227062833.7404-1-shijie@os.amperecomputing.com> From: Eric Dumazet Date: Tue, 27 Feb 2024 13:55:07 +0100 Message-ID: Subject: Re: [PATCH v2] net: skbuff: set FLAG_SKB_NO_MERGE for skbuff_fclone_cache To: Huang Shijie Cc: kuba@kernel.org, patches@amperecomputing.com, davem@davemloft.net, horms@kernel.org, ast@kernel.org, dhowells@redhat.com, linyunsheng@huawei.com, aleksander.lobakin@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, cl@os.amperecomputing.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 27, 2024 at 7:29=E2=80=AFAM Huang Shijie wrote: > > Since we do not set FLAG_SKB_NO_MERGE for skbuff_fclone_cache, > the current skbuff_fclone_cache maybe not really allocated, it maybe > used an exist old kmem_cache. In NUMA, the fclone allocated by > alloc_skb_fclone() maybe in remote node. Why is this happening in the first place ? Whab about skb->head ? Jesper patch [1] motivation was not about NUMA., but about fragmentation and bulk allocations/freeing. TCP fclones are not bulk allocated/freed, so I do not understand what your patch is doing. You need to give more details, and experimental results. Using SLAB_NO_MERGE does not help, I am still seeing wrong allocations on a dual socket host with plenty of available memory. (either sk_buff or skb->head being allocated on the other node). fclones might be allocated from a cpu running on node A, and freed from a cpu running on node B. Maybe SLUB is not properly handling this case ? SLAB_NO_MERGE will avoid merging fclone with kmalloc-512, it does not really help. I think we need help from mm/slub experts, instead of trying to 'fix' networking stacks. Perhaps we could augment trace_kmem_cache_alloc() to record/print the nodes of the allocated chunk (we already have the cpu number giving us the local node). That would give us more confidence on any fixes. BTW SLUB is gone, time to remove FLAG_SKB_NO_MERGE and simply use SLAB_NO_M= ERGE [1] commit 0a0643164da4a1976455aa12f0a96d08ee290752 Author: Jesper Dangaard Brouer Date: Tue Aug 15 17:17:36 2023 +0200 net: use SLAB_NO_MERGE for kmem_cache skbuff_head_cache > > So set FLAG_SKB_NO_MERGE for skbuff_fclone_cache to fix it. > > Signed-off-by: Huang Shijie > --- > v1 --> v2: > set FLAG_SKB_NO_MERGE for skbuff_fclone_cache in initialization. > > v1: https://lkml.org/lkml/2024/2/20/121 > --- > net/core/skbuff.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 1f918e602bc4..5e3e130fb57a 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -5013,7 +5013,8 @@ void __init skb_init(void) > skbuff_fclone_cache =3D kmem_cache_create("skbuff_fclone_cache", > sizeof(struct sk_buff_fcl= ones), > 0, > - SLAB_HWCACHE_ALIGN|SLAB_P= ANIC, > + SLAB_HWCACHE_ALIGN|SLAB_P= ANIC| > + FLAG_SKB_NO_MERGE, > NULL); > /* usercopy should only access first SKB_SMALL_HEAD_HEADROOM byte= s. > * struct skb_shared_info is located at the end of skb->head, > -- > 2.40.1 >