From patchwork Fri Feb 15 22:44:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10816089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EAF21390 for ; Fri, 15 Feb 2019 22:44:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C2863013E for ; Fri, 15 Feb 2019 22:44:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 605D030143; Fri, 15 Feb 2019 22:44:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE4123013E for ; Fri, 15 Feb 2019 22:44:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0631C8E0006; Fri, 15 Feb 2019 17:44:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 012978E0001; Fri, 15 Feb 2019 17:44:14 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E432F8E0006; Fri, 15 Feb 2019 17:44:14 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id A2BC08E0001 for ; Fri, 15 Feb 2019 17:44:14 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id a5so5317406pfn.2 for ; Fri, 15 Feb 2019 14:44:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=fS5mmi3aRfTJ9ZPKh6Kon1+z1mp8jA2r8sJju4C3jM0=; b=IaPcpwqgCE8uupm0FptSImp21pzAPwHzrkwtL8FQmMOvOgmDVuM2CKWyzrFiNKWoxP o6P4sK5er5Vt5bAQAY4xyXrbUcJKSwOT1TJlLDLG9ODw1WK3MRSbZZtBabc2t9xNq9sj xLtBpwxX3SyWGFyS60QZgv2mupOqtzORE/1h6fPz34RqrzK9rj1bWE99l8oiX5EHdeHo cIQt9gdIax/XOmRXZ/1JY8APID8K16eescCMng8XaZjD9uWam7lWA5hSgwUB20hZSFcZ v21nyxzyYf2tN3zALCFUtH55kjJ4A/g7E6bTzeABP2+Swq4gjLFNGzO5zSJcU/9oGclD sBaQ== X-Gm-Message-State: AHQUAubo/rXQ4ZgNBbplKcDJc744Xa1XjlCRfNz4/gkLe3bygy2KqFg6 P72q2fmCoHQYmacl8Ls+F18sjt4AGEGbDyVK8bhGwLr2QVGUf+vuXX38sdvODB/xLS8Jxg/a8x5 gDNRPBdsVmsEO6relz8IEw3O66C6Ozj2TTzOJd98pfmNNqeWc/cAV6qTNSYM7dPEzIUaR0svZ+9 itdYabvLcxGd3kcdDdtiNeSNLizkIRtwXFPNZRmewgod4QzD7SMyIY94PttDhLfHCiYKVMcZQY0 RRuIgB1KwpAlLZfIoXpE16Zg9tBzbGaqTcboNo8ZsQJnO+L4TmCJJNl6CtGh5ePqxwdMN7Fja3Y JVOstiKSB973Ri1wHyiwCFUEFohOlJkb0JgKRedShAfyZbUhCWWB1MN/tCerYz30ZuHLWggaHRA N X-Received: by 2002:a17:902:7b85:: with SMTP id w5mr7787560pll.288.1550270654325; Fri, 15 Feb 2019 14:44:14 -0800 (PST) X-Received: by 2002:a17:902:7b85:: with SMTP id w5mr7787526pll.288.1550270653739; Fri, 15 Feb 2019 14:44:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550270653; cv=none; d=google.com; s=arc-20160816; b=Xnw4RWrgLBBrVr302o3OrWv25hzYTw50G+4l6yP7yKrXkTTTIm0z/I2F1xwdvYpJab ViEo7FzPGxKilb4BoBfBquorrKHIk7KVIHyWtMgWsZjGjNlDQFFVl9wXaR2Tjr/dJ+jx 16vx5Rsb++yblp1j4uVYmzZcrHmZnBxZDjS+k18c7BbFsdB3JqOmApC1lZ1S7cmzzyjY h4BejAmiVT0sXPnOEwl9U4d6Jg9ez0kdRN/NMSVYboImKrPXY/diW60g/XMPf6CxGNQi uj82ib04wRoIHayuZlTgIZM9VKqP3yPfkLF4tfhtla4koIemkrWZzh1ZmurP5uyImXFh z7kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=fS5mmi3aRfTJ9ZPKh6Kon1+z1mp8jA2r8sJju4C3jM0=; b=AFyr4AB1n3N/5yJRAehLnJZlOICaa0Kl4WvuDrKyJViTQyGuGpgy/o+AZit1Wqw6rh ffJk84P+TgCOUni6fiRaqgp/5CTEjOXudySq/lTDclpgFjDKh+pP2peZaw8J02YVgf6s Zx7BCQxkw0xVY197f34YJTUOB5dSgKGOOcDkQoH4sHYXFw6NfJyRHjHZhQpTvS7YkEkX At8VAzk5SOrdknRVDibyiZsx0QPHc2lSUGC4lt/UJqg6CN56qH6HRwGpM9uleB5tvs8r 1JgBNA4x3MUATXXmrQ5sEsUFckIn/UKRq1KfO07yoL0MitERog4P4o/JJl/vjnOx34K8 l7dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vNuDOMtk; spf=pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=alexander.duyck@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c10sor10882136pgh.44.2019.02.15.14.44.13 for (Google Transport Security); Fri, 15 Feb 2019 14:44:13 -0800 (PST) Received-SPF: pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vNuDOMtk; spf=pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=alexander.duyck@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=fS5mmi3aRfTJ9ZPKh6Kon1+z1mp8jA2r8sJju4C3jM0=; b=vNuDOMtkrRDcjIvM34cWSAhjWi7DaxwrterHweE+q54fWc02gttbQplAgtkMGyNr6v I5pndMGUmeOkbofpoyaC97EwN9KzR1zRBpflpPCI4ARgg0U/hKqTN5fW/AAaVda5cPfZ b84zF7FusWmjRjReR0vFfP4DUVPL+NOQrm11mSwHc0lMmzzBlO5rVR3JbrZBzQYP4z9Z pSnur8hx54zXmmXBWSlybPJts2l7U/YLOxfeYgjVP7MN/Z3tg0kQXzf12oKaS5gBGVfi 5dHYwYCUulJb8mFugGLJFCLbloov8VTOs3L5D93afRafxF7f6CmjDrdfK1wGeEMjcNL0 7o2g== X-Google-Smtp-Source: AHgI3IYkBCGWWOk/DvbdZfHFtmtakVD4J0yB5p0EAn9j1LbuYjzDRQBwv3wF7ASJB+gqPc/s6VK9MA== X-Received: by 2002:a65:65c9:: with SMTP id y9mr7720172pgv.438.1550270653333; Fri, 15 Feb 2019 14:44:13 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id 10sm11721400pfq.146.2019.02.15.14.44.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 14:44:12 -0800 (PST) Subject: [net PATCH 1/2] mm: Use fixed constant in page_frag_alloc instead of size + 1 From: Alexander Duyck To: netdev@vger.kernel.org, davem@davemloft.net Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jannh@google.com Date: Fri, 15 Feb 2019 14:44:12 -0800 Message-ID: <20190215224412.16881.89296.stgit@localhost.localdomain> In-Reply-To: <20190215223741.16881.84864.stgit@localhost.localdomain> References: <20190215223741.16881.84864.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Alexander Duyck This patch replaces the size + 1 value introduced with the recent fix for 1 byte allocs with a constant value. The idea here is to reduce code overhead as the previous logic would have to read size into a register, then increment it, and write it back to whatever field was being used. By using a constant we can avoid those memory reads and arithmetic operations in favor of just encoding the maximum value into the operation itself. Fixes: 2c2ade81741c ("mm: page_alloc: fix ref bias in page_frag_alloc() for 1-byte allocs") Signed-off-by: Alexander Duyck --- mm/page_alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ebb35e4d0d90..37ed14ad0b59 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4857,11 +4857,11 @@ void *page_frag_alloc(struct page_frag_cache *nc, /* Even if we own the page, we do not use atomic_set(). * This would break get_page_unless_zero() users. */ - page_ref_add(page, size); + page_ref_add(page, PAGE_FRAG_CACHE_MAX_SIZE); /* reset page count bias and offset to start of new frag */ nc->pfmemalloc = page_is_pfmemalloc(page); - nc->pagecnt_bias = size + 1; + nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; nc->offset = size; } @@ -4877,10 +4877,10 @@ void *page_frag_alloc(struct page_frag_cache *nc, size = nc->size; #endif /* OK, page count is 0, we can safely set it */ - set_page_count(page, size + 1); + set_page_count(page, PAGE_FRAG_CACHE_MAX_SIZE + 1); /* reset page count bias and offset to start of new frag */ - nc->pagecnt_bias = size + 1; + nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; offset = size - fragsz; } From patchwork Fri Feb 15 22:44:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10816091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9AE31390 for ; Fri, 15 Feb 2019 22:44:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 965F53013E for ; Fri, 15 Feb 2019 22:44:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 896A430143; Fri, 15 Feb 2019 22:44:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20EFA3013E for ; Fri, 15 Feb 2019 22:44:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3968A8E0007; Fri, 15 Feb 2019 17:44:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 346A88E0001; Fri, 15 Feb 2019 17:44:21 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2360C8E0007; Fri, 15 Feb 2019 17:44:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id D8E818E0001 for ; Fri, 15 Feb 2019 17:44:20 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id f125so7780554pgc.20 for ; Fri, 15 Feb 2019 14:44:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=arIO7gLw9RNNWVmh9ZBQTlhTkHHBOY3pzYGT4D5o+8I=; b=O29QIKrqa5UBljVAneSkLMoAFFWRctiTFYFjsQzN6jTdHZ9NmnzXKnIPBQwiTn16jP 4h487s4CgAku1IyfspfeZ6ghDIVLXl/oY6j2Aq5sVMOejx42AGXRNiUSLpwOaUtdrevE lA1WFpXUXppaE+9QcQaC3wcwi7LzERf6i+IeV6SOIn+peT4QUYB2bpvMUdr8iVNwciZW lZ25mSyEwi1a2hVkalT4AR/JIVxfZZJcM2aTt+NWHZi5Rue0M8lzuR4h7HWS1DDlSTdC ghxeh/thNr3waNupROLGPbNJ+ktnJXNfMCE+gxB4cSqV/+w6X9CyGO7u+CYbJ3z3nEG0 0Hww== X-Gm-Message-State: AHQUAuZkjYzycoeJNTj186yUiZd2AkOW8izFRQWZbPY2Vfgji3FwC4ew vzDqwQfgjz3aFIMfYXn/C0lP+Z5rRVcBa7CG3eTRqOixALR3iSpkXFQljwuY0xZxubHrbbwtoOf gYdndKWao1ZELkqNZgxzpMht1HnkE4eb4HQ67IkH0d3RpcCyEwZetBhhHNnKbJHOzikDmhbQmsC BTX6lRDm1ErG7Ttbp5wzIWlOgfwh8hxD1s6j3I4XS8MyobFGmD+ydMX8axPYbDsOw/s73dGMp3K vsT6YZQCxHf3QxsmrwCm64KKggwbaVBIl251Cv1ThPe9ky4EpepOqLReN+lqVC3+lG30HIlmME2 0SZoasAD+lb93fmeLkA37U0iA7ksu4NQ2Ul3FUkOYFlksoh3qi4Xmk56qNT9C0RmTScHV201pZ0 o X-Received: by 2002:a17:902:b082:: with SMTP id p2mr9715760plr.299.1550270660569; Fri, 15 Feb 2019 14:44:20 -0800 (PST) X-Received: by 2002:a17:902:b082:: with SMTP id p2mr9715708plr.299.1550270659654; Fri, 15 Feb 2019 14:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550270659; cv=none; d=google.com; s=arc-20160816; b=jCiw1MS2XuiYv/t6xGXvBp7NtxC189JMTOMfeiwF0QNMPM01kSQi7L1oIC0/1Nmdlb dxkO6Ni3sBYmatHBB3kpWyiRDLAK5MwukCsQyWTPpitNjSQTrkFmcU6xenlx9jjj2uSf 2ACvw8ZD49RHXOitL5T6LwFDJX9x3aQPnDg7+F0EY7nFr4UUhKr0oGxV7Ki3NT3bPTcR mB1n+iyWS4rW9jhACbfgV41qn/4frwV35Oh4sbUHUbfRelyG6pRWlKSFgV1fX03iZQ7M 8dWa4bs/zNR/2HtXLVuE6HpJqfsDX6aoHnA8n8xnQkpZVqbR/gXHyGfTtE13KwQAyfSd tVAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=arIO7gLw9RNNWVmh9ZBQTlhTkHHBOY3pzYGT4D5o+8I=; b=rmeEWoJBz76RH9zCO1hggQnfvrv4aDz+WC0TYmchBpetG/BgLZ/l0ltyE55PQja/9w s6I4HrWhQMrJVmaxJQ2G3aq4kMWOQuNe6rNWue9tBb8oU+B81AraUR2FAavS3Aw1J2iV IVojgJeKCPC4gU+SOw+2fu+UaS0ZMkpb5Sy8wQ/7G4WV7WBwrQl2DRcdWJm//T+rmd1k /iC12qvIjAZrDebo9qj7aFB/mW+9ZqdaHmUvDcdG6jrrtVvddGPX6+Iuc/+i++/glkSt wEuFsD6BfoH5KQHkH3jdNjvw5tR9PYppBHVh8OKhnjBDS2xxEtNgWRCIiRpcqA66siWU Y2tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZIjTmsvr; spf=pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=alexander.duyck@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 73sor6389683ple.60.2019.02.15.14.44.19 for (Google Transport Security); Fri, 15 Feb 2019 14:44:19 -0800 (PST) Received-SPF: pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZIjTmsvr; spf=pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=alexander.duyck@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=arIO7gLw9RNNWVmh9ZBQTlhTkHHBOY3pzYGT4D5o+8I=; b=ZIjTmsvrt5YtKJrEdwLrMAsf8mEpOCRVG4XnZE8f7/hixv5N7BRMfMLC4D3pJAZU5e zDX1nfa2aClf0rW49OWbWzCHEAuT7rgox8H2VqyAQOj8LBNSKMNivmSfgzQfNEgj9ZXS dL0b/FNTt9g9fffYzkj+FWPlK3q4HnjUqrTIZKpWUip7e2WEWqOfKXI/313nSJteQ5aS jEZSX5dHjTyTNrzcpAk9guHcEJV8tL/mUGxHX6rBEVL08EVwZUqqgmXn8y9z65H/RXoD c3whsxGpq3rOX2XENIYxBED5hmv9EcsgBSL3oIs9w1+/7s1H38keMlCVVDkdZrN3Z/bh 8wEA== X-Google-Smtp-Source: AHgI3IZk++qbJ+Aw0T8SCVNVtUqt7mSJ6jHdTi9IXyXzVQ9vrAXgtGDbDZi10JSxCZ04o03LLc1tdA== X-Received: by 2002:a17:902:4124:: with SMTP id e33mr12577981pld.236.1550270659310; Fri, 15 Feb 2019 14:44:19 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id s16sm16887803pfk.166.2019.02.15.14.44.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 14:44:18 -0800 (PST) Subject: [net PATCH 2/2] net: Do not allocate page fragments that are not skb aligned From: Alexander Duyck To: netdev@vger.kernel.org, davem@davemloft.net Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jannh@google.com Date: Fri, 15 Feb 2019 14:44:18 -0800 Message-ID: <20190215224418.16881.69031.stgit@localhost.localdomain> In-Reply-To: <20190215223741.16881.84864.stgit@localhost.localdomain> References: <20190215223741.16881.84864.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Alexander Duyck This patch addresses the fact that there are drivers, specifically tun, that will call into the network page fragment allocators with buffer sizes that are not cache aligned. Doing this could result in data alignment and DMA performance issues as these fragment pools are also shared with the skb allocator and any other devices that will use napi_alloc_frags or netdev_alloc_frags. Fixes: ffde7328a36d ("net: Split netdev_alloc_frag into __alloc_page_frag and add __napi_alloc_frag") Reported-by: Jann Horn Signed-off-by: Alexander Duyck --- net/core/skbuff.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 26d848484912..2415d9cb9b89 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -356,6 +356,8 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask) */ void *netdev_alloc_frag(unsigned int fragsz) { + fragsz = SKB_DATA_ALIGN(fragsz); + return __netdev_alloc_frag(fragsz, GFP_ATOMIC); } EXPORT_SYMBOL(netdev_alloc_frag); @@ -369,6 +371,8 @@ static void *__napi_alloc_frag(unsigned int fragsz, gfp_t gfp_mask) void *napi_alloc_frag(unsigned int fragsz) { + fragsz = SKB_DATA_ALIGN(fragsz); + return __napi_alloc_frag(fragsz, GFP_ATOMIC); } EXPORT_SYMBOL(napi_alloc_frag);