Message ID | xlabdyc4izitfdfpuoy2p2hi3abiq4mrrgizdqz45k7xeftbsg@ee6jgncdaqg7 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-70493-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp904761dyc; Sun, 18 Feb 2024 10:36:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXVjPuAkMDvdvHjW9Ugh2FvEOfouJtJcwVKgte+QwMl4BaJ9GHQ/UlueM+BGAjybZ1EKYs6Uw3mKzZWRHrRcrxW2U6GMg== X-Google-Smtp-Source: AGHT+IEjT/hkG/WBDcq5RMy3DoKaMe0LFourB0XOZviJoJAIiWp7Z2x/fbCnWMuFdW6/gzVSXqlM X-Received: by 2002:a17:906:6c6:b0:a3d:4:8511 with SMTP id v6-20020a17090606c600b00a3d00048511mr6686484ejb.69.1708281380198; Sun, 18 Feb 2024 10:36:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708281380; cv=pass; d=google.com; s=arc-20160816; b=M9UrIJ+3Pkiv1EvBMb2kswRNjJ+AZp3aQFxOKKClf2mCfxkZ3i7Ge/63SwyjmqXExe e75fRb9WNZoUbxG1hlKF+RiasuUaBXn4IpdY5LpQmtf6ur5mPcxyCTH9CNxvEnS+jAbr p9Cu0ZDXl2gOjjc/4WCmZKW7NbVJxek2hpvQRUYwzD7bnRPRCFCo5P6SgNyE1QTOCJma FGtM9EeZJF8l0Q07g/tslHbPhkt8LiHd9h0wPaaI6x3ZMtUTu4zV8CdITbNifRC93Yuq Dm7HcYx5A0PLFW8B/33mSFg4qnHoDg3Op/h4mCKhlI5qrUzkJrJvYhOLnuEWfG0ahskR /gPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=rtlFK2N47ATXOiP1HgXvAlQ7VAuyaeK7nB3D2FRWvkg=; fh=QXQqL1WZ9WA83PrkkIf5YD8LBi3i95aEv015B86ExMM=; b=rbL2qDgMzPaCXOQZCb0xHL8lGADdvRg9iB5yiIuKBT4/Ks5WEOTdRlLG3Opcwb1xnY kilj1KBujDT10N4W9k6+lUgdBv1XYvHSZi5Vy0kAjjOkmfAsXfemJ3RUWRikePvyeDzn EvXKmeTI0GaINKHkDBsDPnouXGKMMSPcsG14mRwxo0icNIqwW/4Vovta4hIm7IbevZ96 WhMURMSjKVh+wEUky48UTYtTc7x0AWZ31MTVNktLhGlvVFNIXqbKJAU2OposaPb+PbXu yCypq9zg47+GgolyUi6KzaLU3jP9Dqid3wjRzpt23sv60eO34EPmpVK2FCNX4maKdPd8 G29g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gdawcmHJ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-70493-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70493-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q12-20020a1709066b0c00b00a3de666f9c5si1773182ejr.446.2024.02.18.10.36.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 10:36:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70493-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gdawcmHJ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-70493-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70493-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id CF3A91F21776 for <ouuuleilei@gmail.com>; Sun, 18 Feb 2024 18:36:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6C6D6F501; Sun, 18 Feb 2024 18:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gdawcmHJ" Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (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 A3AB86341A; Sun, 18 Feb 2024 18:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708281357; cv=none; b=W6hnesHSjSOww95oaCOO1P4AQdA+uxvdpugPOyOorfLmPXKL2c0u3SddM9isSYNmU6Hr4Ao/h3mvyZ2aQ4qs2l/LtCH+2m/3kbSZyIWf2WvWJYnA2QdQ+4g+5+PfQ01Q2dB6uK6huxJBkss66ToE2lsRpc5eVFHN4L0b/6tSVdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708281357; c=relaxed/simple; bh=5fuux1HAirtBiYVp43TmFsANlPjwHWYFEx8MXM16p6k=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=it+V73VItZ60aThscE/OC4WhdPeX+PhnZ02ZI7p7LXdWWH1nAxAqg5VI8dzLqtgTfXRt8YwMbs+FVoXF23GGnsy3E/45eQz/l2hGb053lLooAMtYp4C3qg4677u7xMXJuKTzQaxCebeNjtdHQUZuX2yfmisGNCzcVxSSYtnbydU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gdawcmHJ; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-42ce63b1d30so40096361cf.3; Sun, 18 Feb 2024 10:35:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708281354; x=1708886154; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=rtlFK2N47ATXOiP1HgXvAlQ7VAuyaeK7nB3D2FRWvkg=; b=gdawcmHJzaU3npzbZ9iGce4JBxkG0GxOfjtDXK8663kOMUiYKB1w1DXP+L1NZVCcwW L1aZlXHt9b/P0LM0wowItyL4O55UsZh6+6vos3a8BQOQCKzwxY/xEWEWYC1ZfZ3VALCP /Rv+FFpgvUigAVF8XxIWVNHprsPl2184zLVr+6dYIO1Odiem1PrzE6RlE4gKPjGY8PdC KWs6k/3d1f2EJozq77WJNtyMPpZV4XXfYAgpWPaEHjX/dSO3/GZ2PbszxObhur89OQ6H 2clbms3LnOwgVsWKLnWiePjZcOK+Itkb75QtIIZZw3r8F32GZIM84PQ5ul5rzn9x0iVK eXKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708281354; x=1708886154; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rtlFK2N47ATXOiP1HgXvAlQ7VAuyaeK7nB3D2FRWvkg=; b=fQMJyFmEP0n+EKUHx5V0TLKi0Sf4IlDn9WZVTWfFDv4xkvI8r84z+xvuRse8BfEg+V 2W1LJB5ucOXvpH00Oq9Tpepkh/qKkHurp2A6lVn20nWY7uf4rtp0j94FwwtwYCoEOTzy WQ0PC18ND1weCgOJag80EAX8a5BojWwPNKBl8pD0yTTbPRgfIJe7dpzU7PC+X3lhcGrz 9wa8DAe8F1TIDDwkMAiNd8jJfOBDI02MfHm9BCp+Dsyx/1pr/JoqvQzkhGrLLdqgqWG9 Tb1EM/iu04h67xEAyfhmmUlBjhOx1F8ZCTXNXIdINXkQdITfHVKDicQ2klQN8Brkrvav +h+g== X-Forwarded-Encrypted: i=1; AJvYcCXpdJ2NZo5fuOKG7rKBiYwVpthdKZwDn69bS09xf3hdB+Jl89LlWHZIJVeglZbrONGlKtIn/FkXH3L/APYM08uj0VqD8/XtWk3fHdkv X-Gm-Message-State: AOJu0Yzs9xirdttn/3UTMQMPO8KhdJnwwfxQRArVNxp4jWh7yzK1TTYr pjQtXyZFFL1jiF8BFFap3D40tqwy/x4FCZIaC02anHBBD5Z7Qe66 X-Received: by 2002:a05:620a:1928:b0:787:54a5:9047 with SMTP id bj40-20020a05620a192800b0078754a59047mr4612171qkb.34.1708281354320; Sun, 18 Feb 2024 10:35:54 -0800 (PST) Received: from localhost ([2601:8c:502:14f0:acdd:1182:de4a:7f88]) by smtp.gmail.com with ESMTPSA id c9-20020a05620a11a900b007859c6a3a7esm1764078qkk.105.2024.02.18.10.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 10:35:53 -0800 (PST) Date: Sun, 18 Feb 2024 08:35:51 -0500 From: Oliver Crumrine <ozlinuxc@gmail.com> To: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] net: copy routing table more efficiently in rt_dst_clone Message-ID: <xlabdyc4izitfdfpuoy2p2hi3abiq4mrrgizdqz45k7xeftbsg@ee6jgncdaqg7> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791262856308141529 X-GMAIL-MSGID: 1791262856308141529 |
Series |
[net-next] net: copy routing table more efficiently in rt_dst_clone
|
|
Commit Message
Oliver Crumrine
Feb. 18, 2024, 1:35 p.m. UTC
Instead of copying field-by-field, copy the entire struct at once. This
should lead to a performance improvment in rt_dst_clone.
Signed-off-by: Oliver Crumrine <ozlinuxc@gmail.com>
---
net/ipv4/route.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
Comments
On 2/18/24 6:35 AM, Oliver Crumrine wrote: > diff --git a/net/ipv4/route.c b/net/ipv4/route.c > index 16615d107cf0..ebb17c3a0dec 100644 > --- a/net/ipv4/route.c > +++ b/net/ipv4/route.c > @@ -1664,22 +1664,8 @@ struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt) > rt->dst.flags); > > if (new_rt) { > + *new_rt = *rt; rtable is a container of dst_entry, so this is copying those fields as well. pw-bot: reject
On Tue, Feb 20, 2024 at 07:44:24PM -0700, David Ahern wrote: Hi David, You are correct that rtable is a container of dst_entry, and the previous code copied not only the fields of rtable but also the fields of dst_entry. However, the *new_rt = *rt line not only copies the fields of rtable, but also the fields of dst_entry. I have demonstrated this by generating a random number and putting it in the "expired" field of the dst_entry that is part of rt, and the printing the random number that was generated. After the copy, I printed the expired field of the dst_entry that is part of new_rt and the numbers matched. This proves that not only the fields that were part of rtable were copied but also the fields of dst_entry. Thanks, Oliver > On 2/18/24 6:35 AM, Oliver Crumrine wrote: > > diff --git a/net/ipv4/route.c b/net/ipv4/route.c > > index 16615d107cf0..ebb17c3a0dec 100644 > > --- a/net/ipv4/route.c > > +++ b/net/ipv4/route.c > > @@ -1664,22 +1664,8 @@ struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt) > > rt->dst.flags); > > > > if (new_rt) { > > + *new_rt = *rt; > > rtable is a container of dst_entry, so this is copying those fields as well. > > pw-bot: reject >
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 16615d107cf0..ebb17c3a0dec 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1664,22 +1664,8 @@ struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt) rt->dst.flags); if (new_rt) { + *new_rt = *rt; new_rt->rt_genid = rt_genid_ipv4(dev_net(dev)); - new_rt->rt_flags = rt->rt_flags; - new_rt->rt_type = rt->rt_type; - new_rt->rt_is_input = rt->rt_is_input; - new_rt->rt_iif = rt->rt_iif; - new_rt->rt_pmtu = rt->rt_pmtu; - new_rt->rt_mtu_locked = rt->rt_mtu_locked; - new_rt->rt_gw_family = rt->rt_gw_family; - if (rt->rt_gw_family == AF_INET) - new_rt->rt_gw4 = rt->rt_gw4; - else if (rt->rt_gw_family == AF_INET6) - new_rt->rt_gw6 = rt->rt_gw6; - - new_rt->dst.input = rt->dst.input; - new_rt->dst.output = rt->dst.output; - new_rt->dst.error = rt->dst.error; new_rt->dst.lastuse = jiffies; new_rt->dst.lwtstate = lwtstate_get(rt->dst.lwtstate); }