Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp24839pxb; Wed, 18 Nov 2020 15:27:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxy9tv0CSsdyvdgsS1hVmEerhcNPaEZ+chOA78YphzkTha472D79FjWmFWGusRooH7Nj6Pz X-Received: by 2002:a05:6402:cba:: with SMTP id cn26mr4046738edb.259.1605742064462; Wed, 18 Nov 2020 15:27:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605742064; cv=none; d=google.com; s=arc-20160816; b=nvtGcmPDpnRdYVnIT0smATemzp0Uo/iQe8NcmOQ8FJW8Y0c2m35drxbch6GU6g+q9n X8PeIXlOtCwG2RMhuB6p0RXICvTo5SRKFZUrlpbFDYdnyHhj7HB9rimqmkVxH/pZDCLM +Y64frYZPSMoShHWk6mHUjShgpVMLV162J9yVty56NjHjCpZL2qr/XzKoO2PIyJHRmeB bMowMI9YMBhr8x+7J82gQKmYl2PimwEQLDKXddq98s2VpDxhWqf6UY29LZP9Hc+a8i/B ln4i2OgVDCXEQrGgcMu0zce1lZLeJtwUhYRAYBR7ShAtoyfvjO3F90LH2zOV988oPV4E Sslw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=xu24FZ/UR8DlGN7tJpbLTBupLCLZdeo4FZFGZ+EjtnI=; b=ijhbFXna9J7D8HfIoGYYIKTHayktOI9FZwf4cYEi1DTwySXwDILSveMOdzyFj6NyUI IBR+Ej+metC/JJo/k1qL2nh4hvPjUsf+/dyrX/3W9cvYIwEptODf/s0ZmwHeRKh7f05p /ooVA1nn5nVuj9/9UYBAJmVxwU3pvejEKTKQPQb3fqklSKY/2RYDks+n8VQ6Wd/IYr1u nEhu40CWpGqFv6K3dJBKRhQ1JUAvFjW9fJ+XRCGHj20xFJeLMjp5tJRdpRfo+3d9xbOi 89JMquz7R5HJhVJXaI51MGhzmLJjsjc2XnbYDwH/zURF+DInA1KFerixK1MVb9+Nr6Vo ORJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CJB+DNkG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si15886172ejb.512.2020.11.18.15.27.21; Wed, 18 Nov 2020 15:27:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CJB+DNkG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726756AbgKRXXu (ORCPT + 99 others); Wed, 18 Nov 2020 18:23:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:35472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgKRXXt (ORCPT ); Wed, 18 Nov 2020 18:23:49 -0500 Received: from kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net (unknown [163.114.132.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9D99D221FE; Wed, 18 Nov 2020 23:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605741828; bh=xKZACUxyV23LrsDvEaCr6ps7gloZQxSkyTsA5BorCtw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CJB+DNkG/PSKh2h7xzlh2JPaZcjPQ3l5+B7dGhFsGA+6XgmKAdBFt9Kc2o3SBhhi2 215LJepGQZyeu1Bhb1n2PSRb5fyVAwzDUjQEzdlDR9pN/dUQblFNjk+cqP/uFRXaOP FatgJ4J1zUi6bU5mlUmoxZd0BmmysU15OmzzncK0= Date: Wed, 18 Nov 2020 15:23:46 -0800 From: Jakub Kicinski To: Andrew Morton Cc: Dongli Zhang , linux-mm@kvack.org, netdev@vger.kernel.org, willy@infradead.org, aruna.ramakrishna@oracle.com, bert.barbe@oracle.com, rama.nichanamatlu@oracle.com, venkat.x.venkatsubra@oracle.com, manjunath.b.patil@oracle.com, joe.jin@oracle.com, srinivas.eeda@oracle.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, edumazet@google.com, vbabka@suse.cz Subject: Re: [PATCH v3 1/1] page_frag: Recover from memory pressure Message-ID: <20201118152346.5a4fe12d@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> In-Reply-To: <20201118131335.738bdade4f3dfcee190ea8c1@linux-foundation.org> References: <20201115201029.11903-1-dongli.zhang@oracle.com> <20201118114654.3435f76c@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> <20201118131335.738bdade4f3dfcee190ea8c1@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Nov 2020 13:13:35 -0800 Andrew Morton wrote: > On Wed, 18 Nov 2020 11:46:54 -0800 Jakub Kicinski wrote: > > > > 1. The kernel is under memory pressure and allocation of > > > PAGE_FRAG_CACHE_MAX_ORDER in __page_frag_cache_refill() will fail. Instead, > > > the pfmemalloc page is allocated for page_frag_cache->va. > > > > > > 2: All skb->data from page_frag_cache->va (pfmemalloc) will have > > > skb->pfmemalloc=true. The skb will always be dropped by sock without > > > SOCK_MEMALLOC. This is an expected behaviour. > > > > > > 3. Suppose a large amount of pages are reclaimed and kernel is not under > > > memory pressure any longer. We expect skb->pfmemalloc drop will not happen. > > > > > > 4. Unfortunately, page_frag_alloc() does not proactively re-allocate > > > page_frag_alloc->va and will always re-use the prior pfmemalloc page. The > > > skb->pfmemalloc is always true even kernel is not under memory pressure any > > > longer. > > > > > > Fix this by freeing and re-allocating the page instead of recycling it. > > > > Andrew, are you taking this via -mm or should I put it in net? > > I'm sending a PR to Linus tomorrow. > > Please go ahead - if/when it appears in mainline or linux-next, I'll > drop the -mm copy. Okay, applied, thank you!