Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp611402ybl; Fri, 10 Jan 2020 04:01:28 -0800 (PST) X-Google-Smtp-Source: APXvYqw4gIuhvgzNtC0+Oar7Y/l8ZSKtD4TcFGChtxWSiM9lh98nmZXZI/eAjbU7BA3inXoLfcdO X-Received: by 2002:aca:c74e:: with SMTP id x75mr1990718oif.140.1578657688111; Fri, 10 Jan 2020 04:01:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578657688; cv=none; d=google.com; s=arc-20160816; b=IXrpFFSBP4mZgoy191X6dtDSeknBETbDvgV35xS4nxyU7kaOt2/H54nTfrzdDOj2cE Ay9roXwpWh0ERL0t4GJ3pEagDNd12e9GRjXkCRAHGwFt30z33NtulgLgLjI9iQgrv13s 5UgD0f7eZPgAu4kGO3JforzyZYHIS37zUjJpKdODYDL9IuCoO/bf0TmOiLdSXytWvbEp fduLXQ1RrjDuiH+4Cq5RvuNP2RTgdZykaXPsyuPf9mtIDqDreppHbonFpfeanC1ypa/h FtVckU+isOiLLDcdKqF1iAu6XVXngoixVjHtncthgE1G/l9ZNkA0lvn91bNY1bAaQcZ/ aDLw== 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:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=+s42rGCNweegI3ua1aTVb4LJtn2yQPTTMH9TXAr+EXc=; b=kvgU/FM/L6e1xoT73K9QTRpWb0yrtB1/19dS3P3YBk1VHdNC9GiS/smGsZgXn1otv7 nnOvAoj/NtsXtsxyvmwLHYY4AgI8SujD+ffrhuP7zYS6IWBjxWmTTKLI/z2oHCKox3aC H5ESgjeb7dBpsKHElbw9hejWEx/PHwZTq+pR6WhdWyx8us+g7Vn/SqbKW82gBqgIBZ6L 2QI59Nke5ZxnZNKXoNdQjQQ8iDGO1TKazG3n9ubnIat7T7NfDAwNoKE3gdkQ6MB6WBI0 itFwwjrV/JhFbiuJbEKS0KNp9u4mzyo/hwlocNnviiAr4LMf0mANqRnENm8vbupfSoar yVag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GopHQxVh; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si1237197otk.324.2020.01.10.04.01.15; Fri, 10 Jan 2020 04:01:28 -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=@redhat.com header.s=mimecast20190719 header.b=GopHQxVh; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727975AbgAJMAF (ORCPT + 99 others); Fri, 10 Jan 2020 07:00:05 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56262 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727931AbgAJMAF (ORCPT ); Fri, 10 Jan 2020 07:00:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578657603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+s42rGCNweegI3ua1aTVb4LJtn2yQPTTMH9TXAr+EXc=; b=GopHQxVhBCXTXrCikfviJZ+uFXhALS+p5oZlLjXUgRclm3V26xNV01QwtgCdKIjtqt+7eW 2XEmblinhLnLIIiR52bgLV34w2Am0OygCSoplmtTl7xqw0TSXvVAkGRe+jfrJw5Ye1Uhgk Wr2zqBP7wRlZEo48jKGf/QeOYIWmCh0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-zRcpWU8TM7SEnHB-kMypyA-1; Fri, 10 Jan 2020 07:00:02 -0500 X-MC-Unique: zRcpWU8TM7SEnHB-kMypyA-1 Received: by mail-wr1-f71.google.com with SMTP id v17so779071wrm.17 for ; Fri, 10 Jan 2020 04:00:02 -0800 (PST) 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:in-reply-to:references:date :message-id:mime-version; bh=+s42rGCNweegI3ua1aTVb4LJtn2yQPTTMH9TXAr+EXc=; b=nQyMcpxm6LZkFA5dAHJsk88hpNAvjD3IskYbr7cxj9GxibOZ+He1qJolVmVomL8ahR 8q8v+DU7Wc+nZiP0lesG1mys4/w01Ur1tnmoQr1msVt1z6rWUix/qP8wIZdJJg5G7Hax aLCYcTDnDRYyAXhj9p/b5Jo4apvdtZIywAlvIG31jpZd4D8iaHGPIAeg25g0u+txHsut kwFyhdwnCqXb6woaCsRpQ9PQ6x3KmgZ1xxK0WUlZgdKzUqj9mcxL9qeQNd0ypAia+Rxe n99W98AYvnTcSHYD00Dw4oTYeOjeY0ZRl8vs4sXHWRpteurfzdQ4SvmAJCCRulJwf9XU RKFg== X-Gm-Message-State: APjAAAUTNhXgb3majNIiGdihIh3Y9xjdKAbGbHoSXcWMndhm4BygIWYK 3GCOizffA0k6PIehiCQeW1AuIrBQw1gC8ujIGuua3s/yJUvQRbhOwvIrfmK6if4cHkw3zKgbQnN TsKUTaVUvAD3DxyQydegVLwOV X-Received: by 2002:adf:f3cc:: with SMTP id g12mr3210028wrp.236.1578657601320; Fri, 10 Jan 2020 04:00:01 -0800 (PST) X-Received: by 2002:adf:f3cc:: with SMTP id g12mr3209989wrp.236.1578657601000; Fri, 10 Jan 2020 04:00:01 -0800 (PST) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id c5sm2094046wmb.9.2020.01.10.03.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2020 04:00:00 -0800 (PST) From: Vitaly Kuznetsov To: Chen Zhou Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, chenzhou10@huawei.com, tglx@linutronix.de, mingo@redhat.com Subject: Re: [PATCH] x86/hyper-v: remove unnecessary conversions to bool In-Reply-To: <20200110072047.85398-1-chenzhou10@huawei.com> References: <20200110072047.85398-1-chenzhou10@huawei.com> Date: Fri, 10 Jan 2020 12:59:59 +0100 Message-ID: <875zhjr074.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Chen Zhou writes: > The conversions to bool are not needed, remove these. > > Signed-off-by: Chen Zhou > --- > arch/x86/hyperv/hv_apic.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c > index 40e0e32..3112cf6 100644 > --- a/arch/x86/hyperv/hv_apic.c > +++ b/arch/x86/hyperv/hv_apic.c > @@ -133,7 +133,7 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector) > > ipi_mask_ex_done: > local_irq_restore(flags); > - return ((ret == 0) ? true : false); > + return ret == 0; > } > > static bool __send_ipi_mask(const struct cpumask *mask, int vector) > @@ -186,7 +186,7 @@ static bool __send_ipi_mask(const struct cpumask *mask, int vector) > > ret = hv_do_fast_hypercall16(HVCALL_SEND_IPI, ipi_arg.vector, > ipi_arg.cpu_mask); > - return ((ret == 0) ? true : false); > + return ret == 0; > > do_ex_hypercall: > return __send_ipi_mask_ex(mask, vector); I'd suggest we get rid of bool functions completely instead, something like (untested): diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c index 40e0e322161d..440bda338763 100644 --- a/arch/x86/hyperv/hv_apic.c +++ b/arch/x86/hyperv/hv_apic.c @@ -97,16 +97,16 @@ static void hv_apic_eoi_write(u32 reg, u32 val) /* * IPI implementation on Hyper-V. */ -static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector) +static u16 __send_ipi_mask_ex(const struct cpumask *mask, int vector) { struct hv_send_ipi_ex **arg; struct hv_send_ipi_ex *ipi_arg; unsigned long flags; int nr_bank = 0; - int ret = 1; + u16 ret; if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED)) - return false; + return U16_MAX; local_irq_save(flags); arg = (struct hv_send_ipi_ex **)this_cpu_ptr(hyperv_pcpu_input_arg); @@ -129,29 +129,28 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector) ipi_arg->vp_set.format = HV_GENERIC_SET_ALL; ret = hv_do_rep_hypercall(HVCALL_SEND_IPI_EX, 0, nr_bank, - ipi_arg, NULL); + ipi_arg, NULL); ipi_mask_ex_done: local_irq_restore(flags); - return ((ret == 0) ? true : false); + return ret; } -static bool __send_ipi_mask(const struct cpumask *mask, int vector) +static u16 __send_ipi_mask(const struct cpumask *mask, int vector) { int cur_cpu, vcpu; struct hv_send_ipi ipi_arg; - int ret = 1; trace_hyperv_send_ipi_mask(mask, vector); if (cpumask_empty(mask)) - return true; + return 0; if (!hv_hypercall_pg) - return false; + return U16_MAX; if ((vector < HV_IPI_LOW_VECTOR) || (vector > HV_IPI_HIGH_VECTOR)) - return false; + return U16_MAX; /* * From the supplied CPU set we need to figure out if we can get away @@ -172,7 +171,7 @@ static bool __send_ipi_mask(const struct cpumask *mask, int vector) for_each_cpu(cur_cpu, mask) { vcpu = hv_cpu_number_to_vp_number(cur_cpu); if (vcpu == VP_INVAL) - return false; + return U16_MAX; /* * This particular version of the IPI hypercall can @@ -184,41 +183,40 @@ static bool __send_ipi_mask(const struct cpumask *mask, int vector) __set_bit(vcpu, (unsigned long *)&ipi_arg.cpu_mask); } - ret = hv_do_fast_hypercall16(HVCALL_SEND_IPI, ipi_arg.vector, - ipi_arg.cpu_mask); - return ((ret == 0) ? true : false); + return (u16)hv_do_fast_hypercall16(HVCALL_SEND_IPI, ipi_arg.vector, + ipi_arg.cpu_mask); do_ex_hypercall: return __send_ipi_mask_ex(mask, vector); } -static bool __send_ipi_one(int cpu, int vector) +static u16 __send_ipi_one(int cpu, int vector) { int vp = hv_cpu_number_to_vp_number(cpu); trace_hyperv_send_ipi_one(cpu, vector); if (!hv_hypercall_pg || (vp == VP_INVAL)) - return false; + return U16_MAX; if ((vector < HV_IPI_LOW_VECTOR) || (vector > HV_IPI_HIGH_VECTOR)) - return false; + return U16_MAX; if (vp >= 64) return __send_ipi_mask_ex(cpumask_of(cpu), vector); - return !hv_do_fast_hypercall16(HVCALL_SEND_IPI, vector, BIT_ULL(vp)); + return (u16)hv_do_fast_hypercall16(HVCALL_SEND_IPI, vector, BIT_ULL(vp)); } static void hv_send_ipi(int cpu, int vector) { - if (!__send_ipi_one(cpu, vector)) + if (__send_ipi_one(cpu, vector)) orig_apic.send_IPI(cpu, vector); } static void hv_send_ipi_mask(const struct cpumask *mask, int vector) { - if (!__send_ipi_mask(mask, vector)) + if (__send_ipi_mask(mask, vector)) orig_apic.send_IPI_mask(mask, vector); } @@ -231,7 +229,7 @@ static void hv_send_ipi_mask_allbutself(const struct cpumask *mask, int vector) cpumask_copy(&new_mask, mask); cpumask_clear_cpu(this_cpu, &new_mask); local_mask = &new_mask; - if (!__send_ipi_mask(local_mask, vector)) + if (__send_ipi_mask(local_mask, vector)) orig_apic.send_IPI_mask_allbutself(mask, vector); } @@ -242,13 +240,13 @@ static void hv_send_ipi_allbutself(int vector) static void hv_send_ipi_all(int vector) { - if (!__send_ipi_mask(cpu_online_mask, vector)) + if (__send_ipi_mask(cpu_online_mask, vector)) orig_apic.send_IPI_all(vector); } static void hv_send_ipi_self(int vector) { - if (!__send_ipi_one(smp_processor_id(), vector)) + if (__send_ipi_one(smp_processor_id(), vector)) orig_apic.send_IPI_self(vector); } -- Vitaly