Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2285824imc; Tue, 12 Mar 2019 10:35:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOnjIWGeXiSZhYgYL2HM0FOWuEigLPsz+2YESOEnolJMLFGmGol/bHSBjRlBXgQyYqQ72B X-Received: by 2002:a17:902:b193:: with SMTP id s19mr23784449plr.22.1552412151436; Tue, 12 Mar 2019 10:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552412151; cv=none; d=google.com; s=arc-20160816; b=oAonzxsK3ycVOp1uVk29+YZsRTTHcdwngknVLYgLjlAabUXHJTrpMJT82a6MnoiIPW bf95Z8VDX7dF/pQRgDAgqOQS9NvK++lgJQ5OvE1gFAe4MMqgJPktZKyOlrKkWVd9GxNx 3hioQLP7gLKnVb/Q9udDBH8GVSDe4Et6z7XzwQzXZLvc0pHrez+FT6MMydi3ZRxgPr9j OCgP/U2CiY+do+BbKtRRNVyrsr8C9mDeM933nN0rrtxA609TluajAYUDcgWSEGe3cu0j pmYXscyHpARbgPUY86uCiu45c83vTgIyES4BeX5zXRFKu4NUu9EjhIUj38CyKLzV9aZJ dbpg== 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:message-id:date:subject:cc:to:from :dkim-signature; bh=aLMQFMVJhixMG8sPOakzD1aZ1gzCnZ+9/bpni4kwy9M=; b=VmAfQAm9gr0deb491o9fX7PSWFdUWp/0hG+7MVM3TYx92w9ESMNGm2qwaXK+v4WrM2 MQ5zcw0c7hVlqm1gan+uE6o0c9eSjyEgl6kLzWEZnu+xeZuqS5HsEsgL8intJG08QXsx wdDvY2W7kCPemOu+7QxsPcoIV4bOg9VCpOPPpm/ZoNqNMO9CiXXqvW50qF9kHSJkDJWF 4VQJkUWoXBgkJ57p2dqJQAmySE7J2Gqe323pKbv4pcwoNGazHFcMCPOn+sk9izWWP5k6 7Jg6sHrl6Aa0Zv9q6gki5gCxcGgc0oV+2B5zMJWtJVZMnkY06xt25MDzLDv5bmmWdaRY 4+KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=YcMNr4c3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si6592629pgt.254.2019.03.12.10.35.35; Tue, 12 Mar 2019 10:35:51 -0700 (PDT) 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=@rasmusvillemoes.dk header.s=google header.b=YcMNr4c3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729634AbfCLReQ (ORCPT + 99 others); Tue, 12 Mar 2019 13:34:16 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42191 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729456AbfCLRd5 (ORCPT ); Tue, 12 Mar 2019 13:33:57 -0400 Received: by mail-lj1-f196.google.com with SMTP id v3so640305ljk.9 for ; Tue, 12 Mar 2019 10:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aLMQFMVJhixMG8sPOakzD1aZ1gzCnZ+9/bpni4kwy9M=; b=YcMNr4c3NKK9bKjkfZITHqok0FCE8kteFIV+/s93K9uaQXVrNTs2DBzm4K7rPMVK2H gPZ+asT/8f7rNtYcFFfofkMdTl9HKoBU7PinY1Pi1CCmOYUdNwwLiQRLr/fyn6U+BiXy 5as/GBgtQWjaEv8JBBjuBFlDw4MaUUvfrUOWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aLMQFMVJhixMG8sPOakzD1aZ1gzCnZ+9/bpni4kwy9M=; b=pVSoLIyEd5EG/YqrK/FmFoze5yXGZFrhKNaXNimmw4gkGtiD5Gr76bCUQnASCU6S3I XafSJCD+O4wYfRPkfAm43/PBWUB3o/tCUehjHf7nNoj6uPae8xDmZqpAU3FLdLeAj57M d138TlI+GVqHlDNiAsV/mX5cKy+kQE9pjabQEtVzEb8XinH+g8gyq+R67XZkSgbNAj8R FJDmdvvbJLPjede0+Fc24g28KJZJXHLSfg/ouuOCyAw0NH9E6q790C/faCP70vv9zgPv sJhsct2L0nPwtLO++lX7Oc9uUx+oEZe23Un7kJLSVBc+pA5/iAFFYs/dMbOVZbnvsUYv kC3w== X-Gm-Message-State: APjAAAVcFOOLyGkOeScxc9jzb25WLb8n1qj283KdDDEv7WHCZyWeUng4 HghhIkhG0tCGp+8amaXhIwDuRRTtwW6bFa1s X-Received: by 2002:a2e:9943:: with SMTP id r3mr2746272ljj.18.1552412035473; Tue, 12 Mar 2019 10:33:55 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id j5sm1473609ljg.47.2019.03.12.10.33.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Mar 2019 10:33:55 -0700 (PDT) From: Rasmus Villemoes To: Marc Zyngier , Thomas Gleixner , Jason Cooper Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH 2/4] irqchip/gic-v3-its: move allocation outside mutex Date: Tue, 12 Mar 2019 18:33:47 +0100 Message-Id: <20190312173350.4025-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312173350.4025-1-linux@rasmusvillemoes.dk> References: <20190312173350.4025-1-linux@rasmusvillemoes.dk> 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 There's no reason to do the allocation of the new lpi_range inside the lpi_range_lock. One could change the code to avoid the allocation altogether in case the freed range can be merged with one or two existing ranges (in which case the allocation would naturally be done under the lock), but it's probably not worth complicating the code for that. Signed-off-by: Rasmus Villemoes --- drivers/irqchip/irq-gic-v3-its.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 7577755bdcf4..5c8232cff290 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1532,22 +1532,19 @@ static int alloc_lpi_range(u32 nr_lpis, u32 *base) static int free_lpi_range(u32 base, u32 nr_lpis) { struct lpi_range *new; - int err = 0; - - mutex_lock(&lpi_range_lock); new = mk_lpi_range(base, nr_lpis); - if (!new) { - err = -ENOMEM; - goto out; - } + if (!new) + return -ENOMEM; + + mutex_lock(&lpi_range_lock); list_add(&new->entry, &lpi_range_list); list_sort(NULL, &lpi_range_list, lpi_range_cmp); merge_lpi_ranges(); -out: + mutex_unlock(&lpi_range_lock); - return err; + return 0; } static int __init its_lpi_init(u32 id_bits) -- 2.20.1