Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp480221imm; Fri, 11 May 2018 01:10:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZonALiLznV65d7qtoobWUrLsZ5FO1O6VV1y1AUNemBANFEO58GICfPI384GiGpkiOEREF6C X-Received: by 2002:a63:741d:: with SMTP id p29-v6mr3654169pgc.451.1526026255804; Fri, 11 May 2018 01:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526026255; cv=none; d=google.com; s=arc-20160816; b=R3tETYycIUl3q6cQtciIXtBHgOEnOkF3WQXn/WGgTiXMjEuqVADU4JLouSkx9vysdm vkgr63egp8Sd7oOkr3kpj6Bkfxkr6xrAIuS9q0YJK+4hzrfkj5jn4DoQPXsBKCLDVgTj BP4mMBRoy+Pgkjg+Lhq4IH4HAJQzHLxMtYmxbXbBsgDTQsNjh49JV6EnPij2SFRx9Nau ZgVgPNKkD2uLSTdfX7C0uOF/9sIOMnmt+6ailDokkP6nbTEl+pZ5MogFv9QxTNMkKjVN DcGovybqBWdeLTMtaY5fcl3S+97+zBqekrXCeGJtQ1f2+pZj6ETUCt6j9xPIa4NmdOR/ 0bMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=o+9oWwgH20blT58UK2vTtzJcVWqmCKMA/zcej9P6u5A=; b=E3kdHlN8XzqLrQ1Xx05tVWCYpVBJFud+g50twnFIxsQC/FaQED5kHxT3KyZdPVyT/Z 54oaVmlqOt0pI2MuliQQsewXbLQTzjkRm5uvulSFYfRuXA7TeWKup5lslm0vZX7t+RWA vfkLCZnwZ6JlEFDhvT/nuLVl2K0tvS1p6IaaMndo+YCSOTVMmYJMBKvz5yPgmVDU9snK QcZOv1G6FQeC8NTmJctpZ+VGPYmJLGMYPk/6WyAjUOuP/MSinoJlcoUTjV9D7OtGOz4q a/BnVgIGC2HF1TdnH7EsJ4U1jvcAP3aLMxyCH6mfWbP24yOEIfqD3Z0at4oLAgg4d2sa /jyA== ARC-Authentication-Results: i=1; mx.google.com; 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 j7-v6si2910416plk.506.2018.05.11.01.10.40; Fri, 11 May 2018 01:10:55 -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; 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 S1752639AbeEKIKX (ORCPT + 99 others); Fri, 11 May 2018 04:10:23 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:49510 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752153AbeEKIKV (ORCPT ); Fri, 11 May 2018 04:10:21 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="39809424" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 May 2018 16:10:20 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id F34DB4B3EF11; Fri, 11 May 2018 16:10:21 +0800 (CST) Received: from localhost.localdomain (10.167.226.106) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 11 May 2018 16:10:20 +0800 From: Dou Liyang To: , CC: , , , Dou Liyang Subject: [PATCH] x86/vector: Merge the allocate_vector() into assign_vector_locked() Date: Fri, 11 May 2018 16:09:56 +0800 Message-ID: <20180511080956.6316-1-douly.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.14.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: F34DB4B3EF11.A1995 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The assign_vector_locked() calls allocate_vector to get a real vector for an IRQ. If the current target CPU is online and in the new requested affinity mask, allocate_vector() will return 0 and nothing should be done. But, the assign_vector_locked() always call the apic_update_irq_cfg(). it's pointless. Merge the two function to avoid this situation and make the code simplify. Signed-off-by: Dou Liyang --- arch/x86/kernel/apic/vector.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index bb6f7a2148d7..a75de0792942 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -218,7 +218,8 @@ static int reserve_irq_vector(struct irq_data *irqd) return 0; } -static int allocate_vector(struct irq_data *irqd, const struct cpumask *dest) +static int +assign_vector_locked(struct irq_data *irqd, const struct cpumask *dest) { struct apic_chip_data *apicd = apic_chip_data(irqd); bool resvd = apicd->has_reserved; @@ -236,22 +237,12 @@ static int allocate_vector(struct irq_data *irqd, const struct cpumask *dest) return 0; vector = irq_matrix_alloc(vector_matrix, dest, resvd, &cpu); - if (vector > 0) - apic_update_vector(irqd, vector, cpu); trace_vector_alloc(irqd->irq, vector, resvd, vector); - return vector; -} - -static int assign_vector_locked(struct irq_data *irqd, - const struct cpumask *dest) -{ - struct apic_chip_data *apicd = apic_chip_data(irqd); - int vector = allocate_vector(irqd, dest); - if (vector < 0) return vector; + apic_update_vector(irqd, vector, cpu); + apic_update_irq_cfg(irqd, vector, cpu); - apic_update_irq_cfg(irqd, apicd->vector, apicd->cpu); return 0; } -- 2.14.3