Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2183456yba; Fri, 19 Apr 2019 13:59:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhXToR+/a6ZeNI2JNQBPFC2zGS5ldg78KPtlU/4gCw0BuYe59OyVynRewPMLyChv97mukV X-Received: by 2002:a65:6210:: with SMTP id d16mr5806673pgv.110.1555707598050; Fri, 19 Apr 2019 13:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555707598; cv=none; d=google.com; s=arc-20160816; b=zlLxDdCwB7pcFR60GzdBWXUEdEsvtvb2LTrjdy6WiN7whQVGEEyERNMmrMQtAGupnx C7YhhqjHfCQiHNex+1Gn2U86FVvuFnYgmWrGYRKOXXX8pmMbsc0Kb8EdpjEbwb/40WQI ZlXuJxVeI7LydQvtBb1GpDikGO6TGpD8pFtMX+KG6FlaJS4zMk1lhB5dnGkBcfd1qsA3 FtBMQ22FV2IepCB5mL48aFXHxoAHrJC84qMTbd7/euLuvmK6+jkiIo6uE6OI+UhZ8rit FMWNOaDgQIuIX2+81mdosEVZqxeZ8A7q6huI2z2HvzDK5mtkWObsi9HrwpvQFPUNFcx1 +OEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=vIlQTNl4uOjXq7FBgvhtg88HiBQ+qS5s2fo0PEwd1HI=; b=Asn+uGIro8aJuF3SEoVUUWmlb0M5KlbWdhjHt1LK20ujs46Ve5NijP/QZ235y9O7zC GV/fXvlvrPEnYqYu84SnGwFRfhHZWPBqsmxwLwlZccsiUVgoQcwUgVBW4+gqUkt6+mYT LYKX1dFH02thmxm68zoSf7ce4Khsq4dmVEprqmLwqDTB9uWIGnaKxnxyqJpHeKyxqi3d JWnm18EViMqcLcwttz9mYQAN4vtK7A7F4TJXnrtBPD+TbCnInm8AxENz2k33X4B4/ewg 8nh8mGtQqCrIdfH2H8sFUbSPrn7UCdXMdM/u9v33tPXrNZHSqobiS/jWLVA6yoC2OKtU TUoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si5342555pgq.528.2019.04.19.13.59.42; Fri, 19 Apr 2019 13:59:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727398AbfDSU6q (ORCPT + 99 others); Fri, 19 Apr 2019 16:58:46 -0400 Received: from relay.sw.ru ([185.231.240.75]:35560 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726358AbfDSU6p (ORCPT ); Fri, 19 Apr 2019 16:58:45 -0400 Received: from [172.16.25.12] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hHWJj-0000tZ-Rm; Fri, 19 Apr 2019 19:24:48 +0300 Subject: Re: [PATCH 1/4] net/skbuff: don't waste memory reserves To: Eric Dumazet , "David S. Miller" Cc: Eric Dumazet , Mel Gorman , Willem de Bruijn , Florian Westphal , linux-kernel@vger.kernel.org, netdev@vger.kernel.org References: <20190418180524.23489-1-aryabinin@virtuozzo.com> <791f4f23-d931-4ac8-4e60-3ffe46c4ece2@gmail.com> From: Andrey Ryabinin Message-ID: <6651d0b9-4ddf-ef6d-6f53-e1290b7aeeee@virtuozzo.com> Date: Fri, 19 Apr 2019 19:25:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/19/19 4:41 PM, Eric Dumazet wrote: > On 04/19/2019 06:17 AM, Andrey Ryabinin wrote: >> > >> I don't see why that would be a problem. If refill failed because we didn't have >> access to reserves, then there going to be an another refill attempt, right? >> And the next refill attempt will be with access to the reserves if memalloc socket was created. >> We can't predict the future, so until the memalloc socket appeared we must assume that those >> RX ring buffers won't be used to reclaim memory (and that is actually true in 99% of cases). >> > > I just said that the alloc might be attempted "in the past" > > Yes, we can not predict the future, this is why we need to access the reserve _now_ and not > at the time the packet is received. > > The 'being true in 99% of cases' argument is not really convincing. > > You want the NIC to be ready to receive packets even before sk_memalloc_socks() becomes true. The fact that we allocate pages before the socket created I completely understand. But why that failed allocation is such a problem? 1. sk_memalloc_socks() false 2. NIC driver tries to allocate pages and fails 3. swapon /nfs/swap_file /* memalloc_socket created */ 4. We may be loosing some packets because of 2. But there will be retransmit, I suppose NIC driver will try to allocate pages again, and this time with access to reserves, so eventually we all good. So what is the problem? Potential lost of some packets for some period of time after swapon? > If a NIC driver has a bug, please fix it. > I don't follow, what kind of bug are you talking about? The problem I'm trying to fix is entirely in __dev_alloc_pages(): 1. sk_memalloc_socks() false all the time. 2. NIC takes pages from memory reserves 3. The fact that we occupying memory reserves increases the chances that the next page will be also taken from reserves as well, which means more dropped packets than we would have without using the reserves.