From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51122C282C2 for ; Wed, 13 Feb 2019 06:20:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D01B222BB for ; Wed, 13 Feb 2019 06:20:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rYJlwelg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732176AbfBMGUX (ORCPT ); Wed, 13 Feb 2019 01:20:23 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45856 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbfBMGUX (ORCPT ); Wed, 13 Feb 2019 01:20:23 -0500 Received: by mail-pf1-f194.google.com with SMTP id j3so670208pfi.12 for ; Tue, 12 Feb 2019 22:20:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6hvo6lzw2iwUhGT6nmSd9L6felt8qVggtAqU06/uCis=; b=rYJlwelgMbZEEEPZI8OBDCZIvTDOO+LyBycbzdD22Kvuc07yDgJ2h0PsHAJ0DOtUc8 ISft9cZKY7IY1zwr2g95HYrLbiLpDOkm9ti1UmANS+yZZbyMkxq3zpwuhrjMmD3m0abj VKHd3GUKzCGNDszF7Oy0joRigiiIYcHHaU+r4y6HF2k3UPagjpu/4HCKPmfKu7fWqLOr UxzY4N4nusSqz9WJRyEuyzED9U2nfTy12HfKBia1TzYrQxVkfooCWrSEr9ne99u8k2d8 +JdT0vxXiNRmLzYbiNo5P5diwzEoxwsWuPahIq6rR00PDy4KnMKjv16KxYTRm/fWbmp+ E0kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6hvo6lzw2iwUhGT6nmSd9L6felt8qVggtAqU06/uCis=; b=enQkeeMTgBcFdmILffBSGynB6avSmoolMBvl+GJnjXc4W2kZtLha3gRf8/XF/FjqNV rnf31P3xQpJy1Ro1hLFXPCqrehsYbOtXh1KxzwrAI8moaBgvBoC7MJYrp8wJ9jTVxI4Y h+W25gobBwCB9ZiMMsZPnuM8lJHFLAJXvVe9MFSSxUadZP8jrPpiBe6So794UoAvHtBa 7ZYI4lSc+X0dI+lC1OV+K819m5B/YoTfwsTied9OXF6iT4B84ak+2KXX1+5NlZKm8R2u kdGzHhYhIHs+b/CimzRIcwqDj9z23eA4JnCexBsvd093RBylLtx1b5b31oi8cElwI3Pm kA3Q== X-Gm-Message-State: AHQUAuY3PEeqaRkGfATDStoSCcJ6oYmzIzFb9ZQfbGSh6s7rfk3E2vxv NRUFxJ43JwHk4hq42393hqI= X-Google-Smtp-Source: AHgI3IZIzFeFQlIAtYKjw0St5jNtV2dvGjxVtRPmIP5NDoaHjX01bgcSzUBpqrg9E1dZgVsQf/qLCg== X-Received: by 2002:a63:d52:: with SMTP id 18mr7489278pgn.377.1550038822518; Tue, 12 Feb 2019 22:20:22 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e9sm65966981pfh.42.2019.02.12.22.20.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Feb 2019 22:20:21 -0800 (PST) Date: Wed, 13 Feb 2019 14:20:12 +0800 From: Hangbin Liu To: David Ahern Cc: Eric Dumazet , Stephen Hemminger , netdev , Phil Sutter Subject: Re: [PATCH iproute2] lib/libnetlink: ensure a minimum of 32KB for the buffer used in rtnl_recvmsg() Message-ID: <20190213062012.GC10051@dhcp-12-139.nay.redhat.com> References: <20190213015841.140383-1-edumazet@google.com> <5f91bd70-98af-8108-859b-d0482f80674e@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5f91bd70-98af-8108-859b-d0482f80674e@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi David, On Tue, Feb 12, 2019 at 06:08:13PM -0800, Eric Dumazet wrote: > >> diff --git a/lib/libnetlink.c b/lib/libnetlink.c > >> index 1892a02ab5d0d73776c9882ffc77edcd2c663d01..0d48a3d43cf03065dacbd419578ab10af56431a4 100644 > >> --- a/lib/libnetlink.c > >> +++ b/lib/libnetlink.c > >> @@ -718,6 +718,8 @@ static int rtnl_recvmsg(int fd, struct msghdr *msg, char **answer) > >> if (len < 0) > >> return len; > >> > >> + if (len < 32768) > >> + len = 32768; > >> buf = malloc(len); > >> if (!buf) { > >> fprintf(stderr, "malloc error: not enough buffer\n"); > >> > > > > I believe that negates the whole point of 2d34851cd341 - which I have no > > problem with. 2 recvmsg calls per message is overkill. It should not affects ip cmd too much. But for ss, as Eric pointed, it cause performance issue. > > > > It does not negates the point at all. > > The main point was to eventually be able to allocate more than 32KB. > > We need to have a minimum size of 32KB so that the kernel can cook reasonably sized skbs > > Because trying to allocate 4KB only in 2019 is kind of stupid... > > ( Especially considering ss currently buffers the whole thing before calling render() !!! ) This makes sense to me. > > Do we know of any single message sizes > 32k? 2d34851cd341 cites > > increasing VF's but at some point there is a limit. If not, the whole > > PEEK thing should go away and we just malloc 32k (or 64k) buffers for > > each recvmsg. Apart from the 200 VFs example, I think there will be more and more virtual interfaces be used in cloud environment, like openstack/OVS, so useing 32K or 64K is still not safe. What do you think. Thanks Hangbin