Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2024662pxu; Sun, 13 Dec 2020 10:58:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyG3pUdkRfOFICOqYAgRxG+60NfcjOanZJjwie0sRImmIg2MrkDFsXtfu4Lh5ud6xoY0/yH X-Received: by 2002:a17:906:3b5b:: with SMTP id h27mr19477659ejf.450.1607885926866; Sun, 13 Dec 2020 10:58:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607885926; cv=none; d=google.com; s=arc-20160816; b=SCYHcB6lofdM/XYZwyQPoNqwwZi3rvJHfiyhZMt2nUiaB+Q2+IOBuJgkNT4KfgieUR 4QQZUBj2Bml6uefpnYzKS7euSojv/6N+0rOhG1RaHX22toOI5k26WhZ7AlCa8700SYlp +z6NHqLJa880Zi/cAcyXyQzVLUn+0DfO8i1rtt6bn6vLLk2eD1bIkhWV7TD/2mBgd7yZ QYj3q75K+3tGxgilLU/k8LbwcC+6i7z4ImEE5x36GtI+rYxuvg5+fWuzY3WMl2HT3UNG 8Qf1fnr0s0zcML+6xg1N2V8ii9C3YjhbMThSK67zoT46p2TZ2jfkQvvJD5vi9OLxGHmU XqWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:from:cc:to:dkim-signature; bh=CaMA9RW5UtaplKUmsQNUohW2cKU7SkQPGntX3Q5iuX4=; b=BS+Mmlfg0F1/ho58YrjgzHyHUfExfr1sFwuFn83P4UZ4ZB5N0sjWWmvdzTIJGk+7ng DyCSpv1iiR5emJanfGcbbQYcmMrKO3fPl9/r2DAS+hyNVQ/skeP0VK4xq4VBkJgN/Uz+ D1pSCIP8CLthEX/Q0CgLkAdey5GQ7NLORUnDlwZilecC6CKfkE+tQ9p96kvq4u5LZctt 5QD3PDwKHMRNjcgVwOKSEtgQsyNtweqB3nHl7SNFlQ2AaBoqhm7QBx7OfMY+FZkQsLiL uKtToC7d12JPl++XRsKi3Sut9qj1ClRy79p8+VQikTw/+C7zMgH0TtnbU0twLFcx1+/z oaIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TJFilUYH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id mb3si8337699ejb.126.2020.12.13.10.58.24; Sun, 13 Dec 2020 10:58:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TJFilUYH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2437419AbgLMQdp (ORCPT + 99 others); Sun, 13 Dec 2020 11:33:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730046AbgLMQdc (ORCPT ); Sun, 13 Dec 2020 11:33:32 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54190C0613D6 for ; Sun, 13 Dec 2020 08:32:51 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id i24so14584409edj.8 for ; Sun, 13 Dec 2020 08:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=CaMA9RW5UtaplKUmsQNUohW2cKU7SkQPGntX3Q5iuX4=; b=TJFilUYHE2iJDtdrpTCgCza67kS9Ayk6PYibDjmLcoN8r7Yg6bRfzL7pON5le7jkRj 6H+uG5ZYrPd8w55+aJvTghf18n2LJkCmzB+z6qpC+T7gV7BFPtI9rDQCMVH2C8/KQvry kMG2vyLyOTrDOLJBL/AzrpImh2cosKfoWLKDMUHGmq9Jr0BZWSz07uUjV/TcLgYjQ0Gl piPrx/RxKKVw46XyxPaAZRMMQ7SX3OgGUElxLFe9HLC0WnjBhsMmQmXJRM1VpCxnIsWm tNQedvIXhq8TQLNLmO1zQTsnwn1sTEJIo599xml57IPj1chXox7Mg3/nAvarymI+gMXA Etow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=CaMA9RW5UtaplKUmsQNUohW2cKU7SkQPGntX3Q5iuX4=; b=M8vekQxrd97dUTcUxxcxhiuLCudjPGJuKpvWQJkzCUS7b50MrzWWHnNX9TdYFOPBLJ GBRr+AfrUkGoSemWSwdbohjvs5aJ0xhkLxQxbsJ0pxI/fgTPft/HPSElkXOoF7MWk3pn P35X2/LXwZ9PjubdCJ+B8y5kiz7JiYDNxSOJaIy8W9ONxbx4c25nx+/1q3EdPkAG1IVm ShFIzhJCJmMCZv5Eznt6HAb0UpEiImXQ2ZaMpGT8plRLCRVNZJnEcntmMXpmygQCpH6b OPMOb0BbNtOdIeVNEr/MJoWl91RDkOk/9Zy5oAYrGYdO+7smlFTj/f/An0bD14SEleTS bgQA== X-Gm-Message-State: AOAM5318RJ0xDDf4z0izrv15Oagy0PHoXjjHkfH9J/GPfevprTlx7PS1 dmHBk4WoHBdIirjLnH1wCX3EkmpV5rU= X-Received: by 2002:a05:6402:1041:: with SMTP id e1mr1736396edu.54.1607877169581; Sun, 13 Dec 2020 08:32:49 -0800 (PST) Received: from ?IPv6:2003:ea:8f06:5500:39f9:b9d0:a27c:7a5d? (p200300ea8f06550039f9b9d0a27c7a5d.dip0.t-ipconnect.de. [2003:ea:8f06:5500:39f9:b9d0:a27c:7a5d]) by smtp.googlemail.com with ESMTPSA id j27sm11871297ejo.61.2020.12.13.08.32.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Dec 2020 08:32:49 -0800 (PST) To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Barry Song Cc: "open list:AMD IOMMU (AMD-VI)" , Linux Kernel Mailing List From: Heiner Kallweit Subject: [PATCH v2] dma-mapping: add unlikely hint for error path in dma_mapping_error Message-ID: <39581f9a-0066-ad98-094d-d41082145e23@gmail.com> Date: Sun, 13 Dec 2020 17:32:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Zillions of drivers use the unlikely() hint when checking the result of dma_mapping_error(). This is an inline function anyway, so we can move the hint into this function and remove it from drivers. Signed-off-by: Heiner Kallweit --- v2: Split the big patch into the change for dma-mapping.h and follow-up patches per subsystem that will go through the trees of the respective maintainers. --- include/linux/dma-mapping.h | 2 +- kernel/dma/map_benchmark.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 2e49996a8..6177e20b5 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -95,7 +95,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { debug_dma_mapping_error(dev, dma_addr); - if (dma_addr == DMA_MAPPING_ERROR) + if (unlikely(dma_addr == DMA_MAPPING_ERROR)) return -ENOMEM; return 0; } diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c index b1496e744..901420a5d 100644 --- a/kernel/dma/map_benchmark.c +++ b/kernel/dma/map_benchmark.c @@ -78,7 +78,7 @@ static int map_benchmark_thread(void *data) map_stime = ktime_get(); dma_addr = dma_map_single(map->dev, buf, PAGE_SIZE, map->dir); - if (unlikely(dma_mapping_error(map->dev, dma_addr))) { + if (dma_mapping_error(map->dev, dma_addr)) { pr_err("dma_map_single failed on %s\n", dev_name(map->dev)); ret = -ENOMEM; -- 2.29.2