Received: by 10.223.176.5 with SMTP id f5csp2135129wra; Wed, 31 Jan 2018 17:47:22 -0800 (PST) X-Google-Smtp-Source: AH8x227bg0epRfyHn6R22o8F9qYldTmNIREIL1Mqs/p1fL+IGa1n0o8Lacjgf8g0yRCDjvChoL8b X-Received: by 2002:a17:902:242:: with SMTP id 60-v6mr31412767plc.376.1517449642091; Wed, 31 Jan 2018 17:47:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517449642; cv=none; d=google.com; s=arc-20160816; b=Y8GoQImtiMKmMp6TpkEFl7eDudqQ8WokCqiIydazbR54sZEZXm1ByQe2kJu1MMyQ5S 5M0RrRrBzK4xDxWMZZvo/ieyI9lbitJEneBWYMGP1B2pNDUtWQGyRbD0WkCEYPhRYUB5 RTRahCiK7NIvsTXY9BPWgLLDjktWjUE/ferRjxRUo+c5Q5uKrnI2fx7EoDya/wl/vGl8 MW4cLgU61HHSOzhcU1zmI6wFwazsrUJSgPo4gRwWeB7o026999lHf/01PERmIDT/fhBB xb5iyK3M9dzjWBb8sj81J9R1XBtLyaqmSKBIbcVKA/UM3K6FQ3XuR4KcHljWEgm3zVaR W2lA== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=akrVrgYl66UcM2Fn7TKQ70ZtXNhuPFHVkSwjnT0q4kU=; b=mKgpkvF3elcpsxaFTzOYXa2fpxxevbhYq4/4o3hI9urq828o6wzIxbNnTaurZzEx50 ACigaTXsZJnk0wqVKffWpvfA80QtRZ1MmZKiJuhMbT0Cz9Udr0ELqhKH5mvSwgEqA4c5 CX7SdDGv+UFKeBp2qUfa5+0Ra1UKpDh/N+8/JyiLh3T9ltrjEVpcEEvLECSmjPYenwoN yczsUli1edaXnOFQ/TDNG85rr0er6Ha4zvEvonCH6Zcv/aYx12uNR28mIueGyJVWZscF 7He+E20Ltbietco7g2QwRWMTYiCMqNdWsbi/dYtRC4lUD4GqNQhgpPQ5kXScj07is8vE lXiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VFzICJBf; 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=NONE 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 x6-v6si4179019plr.80.2018.01.31.17.46.57; Wed, 31 Jan 2018 17:47:22 -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=VFzICJBf; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932178AbeBABqU (ORCPT + 99 others); Wed, 31 Jan 2018 20:46:20 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:38603 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932118AbeBABqS (ORCPT ); Wed, 31 Jan 2018 20:46:18 -0500 Received: by mail-pl0-f66.google.com with SMTP id 13so2261476plb.5; Wed, 31 Jan 2018 17:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=akrVrgYl66UcM2Fn7TKQ70ZtXNhuPFHVkSwjnT0q4kU=; b=VFzICJBf1TLEVC8A0RKwqQ2vbtCwoKdLNuAAYv8uTZKqG48IsH9KYg0Z+z3B2dXbkV rugHZEnp4eGemBvwcjpGkUKEiDlqAn448hr/72zfXVFKtb5w24znHRBVM48GQMombGT+ 5fEsdqJtZRpj4Bspu28qVU2j1fGLqdSCgv/Z2eXNNN/QWxzaLjKHRI1LMfc7hg5pNJCr rSXM8BJA7xeniNMxE+4hH7oaD3aA8fA5Dk/0u2fK2Yg7aPd84263INphLz2isV1ZVBaI 1kbZACgQJHmPPiNKRlm04s52gPJeuczEmx/MXbGDpvGJBAVSwSCsPva9OopG3SVLo+8Q wmRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=akrVrgYl66UcM2Fn7TKQ70ZtXNhuPFHVkSwjnT0q4kU=; b=qistu1TP1AEvtp/9PQDuCsPHNTdNux6CF4IY3bYBxiklfSzTh2KsOdO+bIBr3EfxCP /ICShR4jYxK/Ww9gZy0QvsuK1sLX6Nj6dGhzQb488eqluuXC/UIOE8CkKGC7qGalLj6G geNvivkE5kEEd6VkUR2Tvsn8bXx+WgWt4/40W8EArvx+s7UJPOjfPeJPiGE4l+wBtLdw Jug0zqOeUeC1JU6FrW1fEffvkMqsGTRytt3Xvq9HO28LcnE5WJHNyNG5Tc2OpGbTjxPU pwm8teFgScwansKfQENh/FREQ3w8doEDX2+0ostYxH0Aq/qKmRHIa4bJEk6j3U5TNy3N 0Y2Q== X-Gm-Message-State: AKwxytdvgWMMDralxpdQsljsCiCvA++YsZajJLRPGs17sGZrjIg7CZch yXuWpr7TE8gCBATRwJHl4AnGfQ== X-Received: by 2002:a17:902:82cb:: with SMTP id u11-v6mr10303302plz.391.1517449577461; Wed, 31 Jan 2018 17:46:17 -0800 (PST) Received: from edumazet-glaptop3.lan (c-67-180-167-114.hsd1.ca.comcast.net. [67.180.167.114]) by smtp.googlemail.com with ESMTPSA id f80sm39255270pfa.1.2018.01.31.17.46.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jan 2018 17:46:16 -0800 (PST) Message-ID: <1517449575.3715.113.camel@gmail.com> Subject: Re: [PATCH] iommu/vt-d: add NUMA awareness to intel_alloc_coherent() From: Eric Dumazet To: linux-kernel Cc: Benjamin Serebrin , David Woodhouse , Joerg Roedel , iommu@lists.linux-foundation.org, netdev , Eric Dumazet Date: Wed, 31 Jan 2018 17:46:15 -0800 In-Reply-To: <1517438756.3715.108.camel@gmail.com> References: <1517438756.3715.108.camel@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-01-31 at 14:45 -0800, Eric Dumazet wrote: > From: Eric Dumazet > > Some devices (like mlx4) try hard to allocate memory on selected > NUMA node, but it turns out intel_alloc_coherent() is not NUMA > aware yet. > > Note that dma_generic_alloc_coherent() in arch/x86/kernel/pci-dma.c > gets this right. > > Signed-off-by: Eric Dumazet > Cc: Benjamin Serebrin > Cc: David Woodhouse > Cc: Joerg Roedel > --- >  drivers/iommu/intel-iommu.c |    7 +++++-- >  1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index a1373cf343269455808f66ad18dc0a2fb7aa73f2..0efef077abc099eb29ebc5cefdd1b996f025dffd 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -3734,8 +3734,11 @@ static void *intel_alloc_coherent(struct device *dev, size_t size, > } > } > > - if (!page) > - page = alloc_pages(flags, order); > + if (!page) { > + page = alloc_pages_node(dev_to_node(dev), flags, order); > + if (!page) > + page = alloc_pages(flags, order); I'll send a V2 without the fallback to alloc_pages() This seems not necessary at all. > + } > if (!page) > return NULL; > memset(page_address(page), 0, size);