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 3DFD3C282C4 for ; Wed, 13 Feb 2019 02:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C803222C1 for ; Wed, 13 Feb 2019 02:04:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZZmzUfGm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733241AbfBMCEV (ORCPT ); Tue, 12 Feb 2019 21:04:21 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42035 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727346AbfBMCEV (ORCPT ); Tue, 12 Feb 2019 21:04:21 -0500 Received: by mail-pl1-f194.google.com with SMTP id s1so381849plp.9 for ; Tue, 12 Feb 2019 18:04:21 -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=np3+eg1h5iCgNyQHV3+xtZw9dY+JSZqqn9gYkuJRwik=; b=ZZmzUfGmiXbYX9ShR8PH0qoEP+hPWlQ3Dl3GLZho3nhfwLJ6kJgWtxwaNODACmQ+3W 4T2stlsyi3kwbzs98jpQbWuGq2t7HGJ19jhc+JF9a78ap4TLrADH5P9GdiIdMAyOHFfY Wy9EeBBqgqtt9KcKVI8BZkrv5RgtfhZN4xMBGArxMKfIUHkqA5YI+kOjH0SZ/tgjXiv5 cJMn/G93mZmufUMr7uFivF7kWN4aYcE3lt4VAaUDFQZZ24t28wPD4ZrHg69hyAEuEKx8 pvzHb3agaQn4Ux4hzRtVdwpZRIDjKmoyLrIkltZKeUVD20DngEK1wUwBFIbssZWy8X7v G8bQ== 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=np3+eg1h5iCgNyQHV3+xtZw9dY+JSZqqn9gYkuJRwik=; b=NtKrGw3+NR2NMD7S3FfBREP6wfB5FEwaQWEcJocxoJn5a5dlcD/IdV0v+ozLlvWhcY /jdehB8GWm5FasLnjoUkcKuHUCfOxmkfEzB5Qdov2b2R+uKxsU9bHtwdAZo/bFWL0T0A 7h24BrPz+iYVrXrS0svyi4wB33kbM77DsmyazQTRXOsQT6M+sA4u1PCDkzetm1EfLj2v J1uYGwZ/uo08veWaDngxLsflNXgfyIyLhLdi4P2q5njzacA83AQ0uCBuZJvjNyaiyy/Y DIrZ3NN0Z2o76gfd6vXbT4vOhRvdmm7cqyh7nIitLWRI9g25B79D1JaGqIyaEOiRFpj2 EgpA== X-Gm-Message-State: AHQUAuZOIwISm5gG2NFlEbxnt+ckK21S5DdhapP07Q7EbNajzBFw2gfH LoweOcjWKCmu4zm7dbzChtk= X-Google-Smtp-Source: AHgI3IbMNPnkRXhR+ZBhwnWHGd2Axv89wwODHHXVa/GtuzdB9sXRdZZcEcN4oWHDo0sJ3wYibTfF7Q== X-Received: by 2002:a17:902:9b96:: with SMTP id y22mr7258968plp.179.1550023460832; Tue, 12 Feb 2019 18:04:20 -0800 (PST) Received: from ?IPv6:2601:282:800:fd80:9dcb:b5fc:3cc7:630f? ([2601:282:800:fd80:9dcb:b5fc:3cc7:630f]) by smtp.googlemail.com with ESMTPSA id z62sm25472057pfi.4.2019.02.12.18.04.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 18:04:19 -0800 (PST) Subject: Re: [PATCH iproute2] lib/libnetlink: ensure a minimum of 32KB for the buffer used in rtnl_recvmsg() To: Eric Dumazet , Stephen Hemminger Cc: netdev , Eric Dumazet , Hangbin Liu , Phil Sutter References: <20190213015841.140383-1-edumazet@google.com> From: David Ahern Message-ID: Date: Tue, 12 Feb 2019 19:04:17 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190213015841.140383-1-edumazet@google.com> 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 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. 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.