Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp640530pxb; Wed, 18 Nov 2020 13:15:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJyH8iKiDZnwWMX72xvBbc9V9pvWOG5PLtrAk4GHuD3bZ/W3VG4tsgRVQet+DooxSbsLJ24p X-Received: by 2002:a50:d5dd:: with SMTP id g29mr28526300edj.379.1605734130944; Wed, 18 Nov 2020 13:15:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605734130; cv=none; d=google.com; s=arc-20160816; b=ScHSpp1TajuuJPoAtboVdWQtF14bmlRBW950eMG5MzYvHqVtXSy/qn/BtvpkJhWFzB P6TMdrYozSK2CneiP17aFBOr4eYAefkI2aNQN/9SmCeetEaTrf+UIT1TNssZkA5ErouT rWg3HNcmoGEWhPT8fPQY4XUano2G47j2JvZnaZUcWEzFDWS9lJKHJ3OHEvjgoaaCtBf7 DQrjLiEFJFWrv/krF/NxIty+JcaZ5xYGUKNB+D9ctwMxWZJh7KgAKY/T7WsUkbshaMJ5 N2PI5KGn1VN7pZwJH2ONS1YHA4ZorhfOREJcG+Ggwhk6P6MvwhNVZnHgC7tX7i+wXKKe lXAg== 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=6hR5WlAnBoGj7zF7ZsvtL2v/ZN8P5DbaOTdVChrRD+4=; b=ywiFS8EPZLV92ip0SGESo59ZbOCmNM5MN7WqMtzr9gAIiCZuFzOu0PAmD/8xE5Gxmf gZpJqF06AR0k8iB6EU4tbtR4+haze/cO6vXCRZkkhwuIGfywBf1JOUUN9LPNuWtSXqaw gFKkHbsJdUs9zK/ZMUvph0e5qBQ5eQuspwmxWvEgpeBZaXBCC2UauRw7qDDGCcBltxc9 oC49AjOVILZQKJZ2muIkeEYP60zGcZtuEcn8+irP02X3zrPdV4pBgLf3FgqZoGIA2OBo QNT5ErZoiZDoXrnQVg2boOKQwcfkh3M0E5bDcPdWtdmYOr/dqg5iG1xjMqaifbDslCM0 fFfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=DxQLDkJc; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f27si19053059ejf.749.2020.11.18.13.15.08; Wed, 18 Nov 2020 13:15:30 -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=@linux-foundation.org header.s=korg header.b=DxQLDkJc; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726629AbgKRVNi (ORCPT + 99 others); Wed, 18 Nov 2020 16:13:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:58102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbgKRVNh (ORCPT ); Wed, 18 Nov 2020 16:13:37 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (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 E33EA207D3; Wed, 18 Nov 2020 21:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1605734016; bh=+8//0K5UnMNFTVC4OTQS6tajK8TIdT39V94cceNEt5o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DxQLDkJc7dR/Owjkxqg6kuft3IOF4f8GMCFk42XTrdXQn+utjhQHzyLVGCYFXgxKw yM1anhZN0FFirIqmnTXx7WuJZhmVUlBq53WYkjinDycCJIbBRT9/6qbnZEXr8AoXrU t4+32GFD2aalCBjNdWef+wGF/2qnkBG9m3Ewr96I= Date: Wed, 18 Nov 2020 13:13:35 -0800 From: Andrew Morton To: Jakub Kicinski 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: <20201118131335.738bdade4f3dfcee190ea8c1@linux-foundation.org> In-Reply-To: <20201118114654.3435f76c@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> References: <20201115201029.11903-1-dongli.zhang@oracle.com> <20201118114654.3435f76c@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) 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 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.