Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2398430imu; Thu, 24 Jan 2019 12:05:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN7eKiIvGDj0Cy50wj6sauPsEi+5N7b1f4UFqwTzbjiS9Vfqv+x2uGTo7VeThjhsamtAYRqq X-Received: by 2002:a63:d846:: with SMTP id k6mr7316592pgj.251.1548360314911; Thu, 24 Jan 2019 12:05:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548360314; cv=none; d=google.com; s=arc-20160816; b=mP6xJJgn7OqVc7oNqKofjhEa95RT7h/nBgBtuGv8DFt74BsF3MFd0kUHnQJY6yDcWj Lw8yunTdG+sTvrJ0OTnzaL31D2lwZ9m5Zlh7mUkHIVfqgDhqcA4PpG/Cz+KmWyu8jWSd XZc+ctCdz96eWIH93FTsqipEwloTwvpqx5frMR/71ERREgFuHUviOSryqeqAQNp3LE32 rK/+7DKRxrSNs9/J2hEuvR1OyRgAnU3Fet8SR0wn8DbsTQN02B8PBEw8ZBqS1uzp0h0R vfCQ3mguZERznIF8rFkBZKInPo7Ivy2cq5Wv1xMvW5NkeYE1P5F0cb6iSuP80H794r9j pyBw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rkenmh8mmLfhs8EmkuEFZmNk+s0lemtxGmP3x4V8fwk=; b=oW31hSfKr3+ORIL4nmbatx9XgZ7/GJr+JVmXxTYsgDRptgWrJT4zoKlipnBo9FkMf9 VD4UexeAykwFjWM4OeTMyOWvbCZhbo0OHsna5nwUrbrKZJV3N6jRartDjkVN7KxmTCLQ t0hWEXGI6b+FyOn2P7hOlhHEuMJCaAQ/y2s3MTYK+TgPqY1ULyFDcvtRFQN71C1rEyfQ x4OWyxYBs1oSb1wK7qj1V9A3RLRtYePVM2z9Em44LKNzgVC1v1OfwFNfvBQn661GXNn/ u/y++pylUHEV83BcZXDQ7T45l2ZUfhmfB68LhT99vgdXJPKA8TN9gOXJVIdto59gagYk PMGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iISMNTBX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17si22060032pgk.581.2019.01.24.12.04.59; Thu, 24 Jan 2019 12:05:14 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=iISMNTBX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731827AbfAXTcW (ORCPT + 99 others); Thu, 24 Jan 2019 14:32:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:60230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731819AbfAXTcT (ORCPT ); Thu, 24 Jan 2019 14:32:19 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 CFAA2218E2; Thu, 24 Jan 2019 19:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548358338; bh=aj7nh+fUPBGKIe1rgwHnuOqeXvtNn9keuPO99YZ7nzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iISMNTBXx1ud7ZzQLVdf7VTFOyB8FzRufrPkdttPEhiPVEyipB7o7HvF/If1V0zZq o6vsxJM+KK+Ib188maS3ygqeLrfr91jqQRFE8aGq/R2VDg32L5/es2ocPlFR+QTZE+ zggehDVnN7+VbuHf3qten4qIQkMvc1Xsjkw4dgro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Rientjes , Eric Dumazet , "David S. Miller" Subject: [PATCH 4.14 04/63] net, skbuff: do not prefer skb allocation fails early Date: Thu, 24 Jan 2019 20:19:53 +0100 Message-Id: <20190124190155.604407571@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124190155.176570028@linuxfoundation.org> References: <20190124190155.176570028@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Rientjes [ Upstream commit f8c468e8537925e0c4607263f498a1b7c0c8982e ] Commit dcda9b04713c ("mm, tree wide: replace __GFP_REPEAT by __GFP_RETRY_MAYFAIL with more useful semantic") replaced __GFP_REPEAT in alloc_skb_with_frags() with __GFP_RETRY_MAYFAIL when the allocation may directly reclaim. The previous behavior would require reclaim up to 1 << order pages for skb aligned header_len of order > PAGE_ALLOC_COSTLY_ORDER before failing, otherwise the allocations in alloc_skb() would loop in the page allocator looking for memory. __GFP_RETRY_MAYFAIL makes both allocations failable under memory pressure, including for the HEAD allocation. This can cause, among many other things, write() to fail with ENOTCONN during RPC when under memory pressure. These allocations should succeed as they did previous to dcda9b04713c even if it requires calling the oom killer and additional looping in the page allocator to find memory. There is no way to specify the previous behavior of __GFP_REPEAT, but it's unlikely to be necessary since the previous behavior only guaranteed that 1 << order pages would be reclaimed before failing for order > PAGE_ALLOC_COSTLY_ORDER. That reclaim is not guaranteed to be contiguous memory, so repeating for such large orders is usually not beneficial. Removing the setting of __GFP_RETRY_MAYFAIL to restore the previous behavior, specifically not allowing alloc_skb() to fail for small orders and oom kill if necessary rather than allowing RPCs to fail. Fixes: dcda9b04713c ("mm, tree wide: replace __GFP_REPEAT by __GFP_RETRY_MAYFAIL with more useful semantic") Signed-off-by: David Rientjes Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/skbuff.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5154,7 +5154,6 @@ struct sk_buff *alloc_skb_with_frags(uns unsigned long chunk; struct sk_buff *skb; struct page *page; - gfp_t gfp_head; int i; *errcode = -EMSGSIZE; @@ -5164,12 +5163,8 @@ struct sk_buff *alloc_skb_with_frags(uns if (npages > MAX_SKB_FRAGS) return NULL; - gfp_head = gfp_mask; - if (gfp_head & __GFP_DIRECT_RECLAIM) - gfp_head |= __GFP_RETRY_MAYFAIL; - *errcode = -ENOBUFS; - skb = alloc_skb(header_len, gfp_head); + skb = alloc_skb(header_len, gfp_mask); if (!skb) return NULL;