Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp337531imj; Sat, 16 Feb 2019 01:18:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IZl/kN45DNuag3NX8915EbWXWjEfpwpCMz96zr7E89hvDRfKW4ESxkczgMXlhVwVp/9uZ7T X-Received: by 2002:a63:9306:: with SMTP id b6mr9015116pge.36.1550308721837; Sat, 16 Feb 2019 01:18:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550308721; cv=none; d=google.com; s=arc-20160816; b=dwOMXH+AYkjnctk+9Kpz1FSLfl7bP1nxdikJEB23k0sJFon9hBzVcHEz8mBvwap0NU nSF3F9nTGZ5gM+wTAEQffb9emxVyyAIxgNApRyi74cm+KqmQAbXCcx07nxu6F3QQWCXN 0h647vnmZzSOgLYx7mRDWUV0sE3221iasSdNnEmAImnFmLzD50baogEDFChkddnNDt5m W4YDxZvqnlZbHy4WzK7sIqZjAYpZSDWJHxxCWc7bxH0pdv+DRpdbssFleitUtjYwQbBZ uv/kRSZVY4vWnPQTWzbmeMBfKRAoEVWiXhKZ6rGxUKGToQC7shSLyXgJ4CCW8q/7XTrT FbKg== 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:cc:to:from :subject:dkim-signature; bh=arIO7gLw9RNNWVmh9ZBQTlhTkHHBOY3pzYGT4D5o+8I=; b=YZuQVlsjai70GuYdgwqvXSYO5T/GooY3WA50E6pqMz3O0Ry9yVFt9buxaCvwD8thfo 9igpqKpkuhBeCKtzh3Ry4x5+rmwH3hOCUd8hVcDg5VkJZFkuaBinLBAZuXxcKph1jmZx e/DlYe0F9keyx5OnTlOmOHLfMeRuNuOb3ss/ZFgbcjayJhG1oaeUppmeRtK0/twxt4cx De//ritGIfp9LFg+b0zcXBphb2lIT3q+R74NOc++oS3QaDQJUjpX3QqA8++WLwszGe9r aCd3FEuwXaNsa4TU2haxSPa13O7e2G8kOwsuK7PAGzYWdlZkH9kOkMEBdTm08athAfz3 mj9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZIjTmsvr; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si7674666plt.356.2019.02.16.01.18.26; Sat, 16 Feb 2019 01:18:41 -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=@gmail.com header.s=20161025 header.b=ZIjTmsvr; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404549AbfBOWoW (ORCPT + 99 others); Fri, 15 Feb 2019 17:44:22 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:45460 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404529AbfBOWoU (ORCPT ); Fri, 15 Feb 2019 17:44:20 -0500 Received: by mail-pl1-f195.google.com with SMTP id r14so5623001pls.12; Fri, 15 Feb 2019 14:44:19 -0800 (PST) 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-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=arIO7gLw9RNNWVmh9ZBQTlhTkHHBOY3pzYGT4D5o+8I=; b=ehwNhCDqNjHdxA87cbKgZKiPT4R++z9UUtCNurJzzqqR6p7/+HNe7TLQW4w5G6/dUX 7hGryD6NqKFqH1EWcyXMTz1tH8ZtQ97PuLyV/r5T1CnvQ2wiFD1atccgj7EDwzlQnHFW Zn6R1c5diewIl3DSPGPB3g++xf8UY8Mzbo0uNPPh0rVvhi8a56B0W201w2e4/bovm89Z yHGqQpOulR78kiALqfH9pE8zInZwHDHUUj6oyGF/5pF6Q9nzSdUjJs9/R+/icI2x4Mzu siyEO+Ag39vWerQE2CztL1ryHWY5kxs1wPuEoyqEVFtNun7wWxW1O8civtgnt5sFAto7 DtHg== X-Gm-Message-State: AHQUAuYYNIvv/OD7wOZEk98ltqYRnr2dK9i/nL4NgDSpSZw5yv6YEdC9 J1DqrH+7upW7uSyv9XL0VYLq8/sb 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);