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=-7.1 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,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED 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 B4E66C282C4 for ; Wed, 13 Feb 2019 02:08:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 837B7222C1 for ; Wed, 13 Feb 2019 02:08:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vTu5vKGo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733195AbfBMCIQ (ORCPT ); Tue, 12 Feb 2019 21:08:16 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43322 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727346AbfBMCIQ (ORCPT ); Tue, 12 Feb 2019 21:08:16 -0500 Received: by mail-pg1-f193.google.com with SMTP id v28so372003pgk.10 for ; Tue, 12 Feb 2019 18:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mNl6F9OC7FuE7rrMi8GwfJ+UtvH6cKdZK81F8bSQvPI=; b=vTu5vKGoJq3S0aMLgG0dv0gkB4DVbU9mLVxZwMxZKcfMonEVx+Ovo3GF5V7FPcEbtu JCAjCDxQnutQh9WmHxLiJDEBHqCKxyvhXUt8sBbj+bJaj92YUQzcPZFv6LTQdyz0zY1D x7sd8QCsFfaRFiH8nZ1Sdqu5XLSm1Run0XZGmf/M1jBF71dxEQLv8Q6DlzgB+tP996w5 xMFFM2EPDU3HPoR5448bAidFY4o72exQcb/VU8Ohkxsfs1N1XAMx0KtQ3sLhJRWoFGcs 3HVuu/Wa3tEUlmG99MVV7i8U4OpiTO16irDTxif2lnFbepStPVQCVKEP8/a3m7L5YYzy SOww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mNl6F9OC7FuE7rrMi8GwfJ+UtvH6cKdZK81F8bSQvPI=; b=HBYzhCjGvN5B5IZGh2DJsK15pr0H1Lf8t5YRsU2lzPKQwUoyxx+hrIdjTDSfGQXCTF xXduw5ghAlS6w1TDwSV6uqLEWNe0a0cD/VvOuAik8ylNN0S761fReGk/M9Ikm3bQ5j6v qcP0W0smrMQkeQhOFzZQ/QHohBE7Dqw0w8eWz0/WrcUx/1IrbO5MzlV8qcTegjjNF/Z7 hWSdiEMDMUbww5eLPr8QEYCc4elLXgW4Qv473YcOXPnkZRjmroUQwITJloBeMLtgLmpU CS2YEV3aq0ccD0YzaDaM1Gsy0/q8mKNb9D45vwXjEKJ0tlqQ3mf1bkuzMuJo5G+CeQk0 zu/Q== X-Gm-Message-State: AHQUAub6gRkOQAPbPrhny09lr7aq0xnkn8VhHjvnQCkmJ+eNNi6pQOJ1 EhlKvHrcK6EdlozOVnIZIrc= X-Google-Smtp-Source: AHgI3IYU4mkybyPzJxO8k1x+5vTkm18owcEHh/1bj+6UMCshklQuaft3yHJiBaoE2wglUtmFgbMVVA== X-Received: by 2002:a62:9305:: with SMTP id b5mr6994653pfe.10.1550023695243; Tue, 12 Feb 2019 18:08:15 -0800 (PST) Received: from [192.168.86.235] (c-73-241-150-70.hsd1.ca.comcast.net. [73.241.150.70]) by smtp.gmail.com with ESMTPSA id g128sm23758530pfc.164.2019.02.12.18.08.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 18:08:14 -0800 (PST) Subject: Re: [PATCH iproute2] lib/libnetlink: ensure a minimum of 32KB for the buffer used in rtnl_recvmsg() To: David Ahern , Eric Dumazet , Stephen Hemminger Cc: netdev , Hangbin Liu , Phil Sutter References: <20190213015841.140383-1-edumazet@google.com> From: Eric Dumazet Message-ID: <5f91bd70-98af-8108-859b-d0482f80674e@gmail.com> Date: Tue, 12 Feb 2019 18:08:13 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 02/12/2019 06:04 PM, David Ahern wrote: > On 2/12/19 6:58 PM, Eric Dumazet wrote: >> In the past, we tried to increase the buffer size up to 32 KB in order >> to reduce number of syscalls per dump. >> >> Commit 2d34851cd341 ("lib/libnetlink: re malloc buff if size is not enough") >> brought the size back to 4KB because the kernel can not know the application >> is ready to receive bigger requests. >> >> See kernel commits 9063e21fb026 ("netlink: autosize skb lengthes") and >> d35c99ff77ec ("netlink: do not enter direct reclaim from netlink_dump()") >> for more details. >> >> Fixes: 2d34851cd341 ("lib/libnetlink: re malloc buff if size is not enough") >> Signed-off-by: Eric Dumazet >> Cc: Hangbin Liu >> Cc: Phil Sutter >> --- >> lib/libnetlink.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> 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 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() !!! ) > 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. >