Received: by 10.223.176.5 with SMTP id f5csp1987926wra; Wed, 31 Jan 2018 14:46:43 -0800 (PST) X-Google-Smtp-Source: AH8x224dhos/g6QKK4VDduPqJlqod3+VP1RQkxTBkZuazuTaV4LVqxZa+JJ1ti3Af2LkroCkqcdk X-Received: by 10.101.72.69 with SMTP id i5mr24146573pgs.9.1517438803026; Wed, 31 Jan 2018 14:46:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517438802; cv=none; d=google.com; s=arc-20160816; b=i13SbZxb4OCa8MkJ9Tx6Fele7wtEK49zuBWpZvJwXPyWuAaAe8efH3K+7R5/oGDcNg uioALxz7NbkFDSpYOiClAUG7+ElpUcWtyR6YQRX/FnmhynfRzu7mqVEFYi+QNpXYmPeT dy5LNX2H90QsK1N9u6DKgNBTdf5uieNCAoVgUrIDb/3vA9FvPJ+NDwkHtPGyxX3qEcYx FRwyTnVrjDzWAhMcigJCa+K02WhzXkOvuqdnT8qCs9dDnb87wyjGpo2SQhxO3Au8tCqc ru3+Lq0x1kS2TiOIwVPPCdSNk2M1yX1D+brxsZMWM4i2jmtM4jgzVoYfspZuqoOFBddo X+tA== 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 :date:cc:to:from:subject:message-id:dkim-signature :arc-authentication-results; bh=aHH+YdGyst4KbIxxUcyTJ2FCUuth4fzOd/ZqCVVCbSM=; b=iC5T68RfaXeqCbm9iuEy35iWDgObKlHph40EzrwJeF9bXX8hbcIcpmekokgeG8RkDw VVb6TMq6ZJD8JzIhoLM1jqwCLVttsnyzFz2tH3Su47VcWDQ4ppqqmSI4Yi3BmLa5fKZG WO3kHvUkei6vnA90Nwg1+iHNJ0Tru6sOYESvv8eEC0UXqKeaToaavU5sFro/yzstbyG2 vPwVQxC81rD9NpZggOOWT01T7bpE9rTMA3efK5Ue6jFfHfupl4YHcZMwkCfbjBajCCql OVM32oCo1hOQcSQYVo8u2GGtTAXnfRo1NOZ4oQ1aSj2T5TVJYh0vaIFGD/lcbTHsGpX2 rhkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PYtW+LgF; 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 s15si237170pgc.166.2018.01.31.14.46.28; Wed, 31 Jan 2018 14:46:42 -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=PYtW+LgF; 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 S1751912AbeAaWqB (ORCPT + 99 others); Wed, 31 Jan 2018 17:46:01 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33244 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751650AbeAaWp7 (ORCPT ); Wed, 31 Jan 2018 17:45:59 -0500 Received: by mail-pg0-f68.google.com with SMTP id u1so11288676pgr.0; Wed, 31 Jan 2018 14:45:59 -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:mime-version :content-transfer-encoding; bh=aHH+YdGyst4KbIxxUcyTJ2FCUuth4fzOd/ZqCVVCbSM=; b=PYtW+LgFb31UgFz3UeUCMJsjyLjIcJ2UwlIHZS4eoWyKJKY1cPIPpPdG/yyjQqTzL6 GaPmUfHahNMWusb/ys4vgvXpbQT/qW+8hQwhOy+956xiDMwJZf39t3Uf1ra3DOaI729C J0pz3gdcRfiyAU3pCAMum/bpknln+5DUU7rZQ8/pIvu+8JPBVHP3QE/BVVFiwQWNnFSV AqN/Qhh7G/gv5l+PxLRVByeP1AKchEM4FxOa0RqvpU/ux2SQFwG2rjKzmr/SifllfwKF 91QRl1rjAR3Us91iHiZA0z0StjJEElH2AQTpv+mYOsVtjgsXntyNjr0uWBN9hw7SIMna KhgQ== 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:mime-version :content-transfer-encoding; bh=aHH+YdGyst4KbIxxUcyTJ2FCUuth4fzOd/ZqCVVCbSM=; b=jXcUF+Ckhv7hpTN4hJSYjX5VkfUly3myk6g3DbQ+M9bdmoFxYtrzKFIDZ6qasVYOJ/ Ct2nyox07bW/NnfBOTkebv5zvLy3N8M0xE/9rXUakU5Qi4BGxkObipI9V8S0xUZbTe/W 7Vz+FuDqktcFZqYg+V++HFoHfEG3nM/TQDLJTgetfMCGqcJzyAEmZ0vJEA92VL/oVn7B /n3y5t1L4Mxn8J33AK//5cEY9BaVWnWuBcfXrP65eQ4zmqRbkjfS3CtlIVhjW20O5EiR XXtfhR4IRmYNrPJZtXubDnnYahUU1lv0eXAAImoxqXB9RJ1epVLkzjiNzX8ZR0vExZjv Fh7Q== X-Gm-Message-State: AKwxytfoN4gz9MmCUaIkW+HnJVs2GJkAJ3OzyucQZ37GNhtPdJ1cbst1 zIN1B3m8Xi72oYfz+BZiciTeZQ== X-Received: by 2002:a17:902:6e01:: with SMTP id u1-v6mr30071220plk.12.1517438758978; Wed, 31 Jan 2018 14:45:58 -0800 (PST) Received: from ?IPv6:2620:15c:2c1:200:e081:603e:7fdc:75e? ([2620:15c:2c1:200:e081:603e:7fdc:75e]) by smtp.googlemail.com with ESMTPSA id 14sm26903113pga.12.2018.01.31.14.45.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jan 2018 14:45:57 -0800 (PST) Message-ID: <1517438756.3715.108.camel@gmail.com> Subject: [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 14:45:56 -0800 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 ---  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); + } if (!page) return NULL; memset(page_address(page), 0, size);