Received: by 10.223.176.5 with SMTP id f5csp2356402wra; Wed, 31 Jan 2018 22:35:30 -0800 (PST) X-Google-Smtp-Source: AH8x224e/6fUU1DZsYS2QS9CqFe27TjPbEp9IIHdkL40H9K2mTk0V/9MVBVlWXxsD9A1b2IeGjki X-Received: by 10.99.56.18 with SMTP id f18mr27770062pga.438.1517466929991; Wed, 31 Jan 2018 22:35:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517466929; cv=none; d=google.com; s=arc-20160816; b=THsjE6iWZVnb5jTuSFDrmYvIHzXP0aok1YNQfAcx6om8XVMdV+FUZGgw4jrEKQanET pY9Fqref1OWv10Vc2ZfLplxWuMGncd3ZAIvkLZDiI57YZ8QH4bbu+mS89JvxbbT3Ae6q 9f9VudPgpnnTqwU7Ys+CV9zO7d9J0a7Pe3+dYrcZHao/qh577LXopJW/ZPBw5J6LJqZI SfM1FehsJeaMxVR20zbU51J95brWTem1KnTVOm5W5KKlFrvCc/AtxJ41EWG6JJhJ/TSI /a6O7F7IY3aoQL4po1LplNq63gVJum2nbYsqB1tC5ufMSkvAeiQTdwYoBW5SAgb7xpdO nlkg== 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=2+/mynPJQhgyZeVDwjk11CuwiZbpxI/RNuacfrSMYNg=; b=sG4ISyqnJAq5fb6QS2kynIn4ObHDS0ju7zPsjURdV9bjRoMBmhJXyOrCRj6oOxO2jC jjr4OII/sGUFb87P1CxA+r/Zo1dA7x5UrMmQLlLbrLbkZDT7ahnGCehMANOD+Qo4CWRV JM5dslskqCqgQQJpo6TgbEXbXsYcxCj7U6VLWQx4o+H4/HcCZz8ETq8fXz2TbzniP4TA utnqaupWCMjgWfT2kgZTv1LZbBiUoO/L0MY2aOfer0Al10EDq/afaYdiHKDDraKEvUck sMfcSCudqU33RGqa+Jjc1E6g3i8aWfsYm5xCa4mQ658Yh4A+a8NjCVsYk6uqMt+y225h TIOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OgUWixpJ; 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 e4si2714798pgn.428.2018.01.31.22.35.14; Wed, 31 Jan 2018 22:35:29 -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=OgUWixpJ; 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 S1751701AbeBAGeF (ORCPT + 99 others); Thu, 1 Feb 2018 01:34:05 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:38565 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751635AbeBAGeD (ORCPT ); Thu, 1 Feb 2018 01:34:03 -0500 Received: by mail-io0-f195.google.com with SMTP id d13so17959068iog.5; Wed, 31 Jan 2018 22:34:02 -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=2+/mynPJQhgyZeVDwjk11CuwiZbpxI/RNuacfrSMYNg=; b=OgUWixpJXau9oHkDgZoGtNIYQNaPg/sx5TJXDCijBl2lm1Zyd3x4W5aVy0abFgOCtr 92mBEd+x22Z5xVLVlpk3+x70wQxe/vFFUT84G7rGtmI8OBB9KN4DAuXBGSSduTuok8kJ oO1XJwEzHrP4PB3PCOuTkbsaB3pA9cVk2UJCXJ3PYorkbQmVgHqbYSolloprbiskNzoy CkxILkZcPcWW34snp7LF7JA9a+pbMLxBzLVd1CJ1xp84oz3XD4BxWc8Wf/pzsm8BY0Mo ynRf+4Af5IbwM+PyiQYO2IdF9rCshhr4Hd8ib4uVzRSl4cQ1l9TAd+RpM8UxY70zLodw HNRg== 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=2+/mynPJQhgyZeVDwjk11CuwiZbpxI/RNuacfrSMYNg=; b=AvzAjua+EnbD5iQf/j05b03DohSG9+VYTUUq+OsadFhWM2lzrhEPmkQF+1HXtemdpT sdj05hk8YipslMUtNQmzXyfcXYv6WZbkKwVyJ8hfQNIZd+gm7WHQ6nSJbmvJ/QIl/y+p +2ZvthKjCkwMk14C0/kVNlUCsDnDARROMy8dP7sCpurXPmZn2VYOns1kEIb/MUv/AAxx /DCfedKpET+WqUB5cKiFT3ncnuWMNZWyxd9VAG+PktjLwfDBv9vHY8KXw8Do3gCEl8Gn hlzyW7zw4/VAIwdtr82nGF/A/zN4EK3I12k3k3cUPBv6BBeiYbiveo8rlucqXGkJ2N20 JcZw== X-Gm-Message-State: AKwxytdZHN/JblHzsk76eqhgmf9GG6HVjWkyhkGcWsQHSyKUEuUkYosv tEz2XDrv9XdT87VQmzJv1EAeAA== X-Received: by 10.107.192.2 with SMTP id q2mr38563383iof.112.1517466842176; Wed, 31 Jan 2018 22:34:02 -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 64sm8410236iox.0.2018.01.31.22.34.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jan 2018 22:34:01 -0800 (PST) Message-ID: <1517466839.3715.115.camel@gmail.com> Subject: [PATCH v2] 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 22:33:59 -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 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 --- v2: no fallback to alloc_pages(), this is not needed and might even hurt in OOM cases.  drivers/iommu/intel-iommu.c |    2 +-  1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index a1373cf343269455808f66ad18dc0a2fb7aa73f2..3c538466a98bdb8fffdca688462b1350d536791b 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -3735,7 +3735,7 @@ static void *intel_alloc_coherent(struct device *dev, size_t size, } if (!page) - page = alloc_pages(flags, order); + page = alloc_pages_node(dev_to_node(dev), flags, order); if (!page) return NULL; memset(page_address(page), 0, size);