Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2758078pxb; Thu, 11 Feb 2021 23:54:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJztHffAqr/DWBsLu+H08N3MzcMiQ/qDJ5jpibXD/gmRUwELRL9ZOQBlXL3zBk5qagVFr83R X-Received: by 2002:a17:906:7d09:: with SMTP id u9mr1729850ejo.380.1613116462271; Thu, 11 Feb 2021 23:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613116462; cv=none; d=google.com; s=arc-20160816; b=CLGrxVA2o/gJ4ie+40mXtAL6bkSBj1Hm1sz7ijRhWvJzgFScvu+xW1AIVQH+hgOW4x WJAcc5G6J9vEvDqBl/LdpaWHq1Ax1kYjDm0UknnKkKIbAMu4Q+ZItzAqsEIP0es7gvq8 LUiMSLQWHVRqOrLEqEQc4G+S691uL/Uohwagg3CubU3bPE3HGcQnWlpcyFf8mXDq0E/S HpXoU0bhfLybXHGExryRZQUDhdaAiIecNdtd49s8CowT8pHvlXbPdzpYHpcAo0N2+lvw xyspx5ETOA5w7/RwaCwMYvldh6Wm6qZlxJ4gcmOlbwpJ4N+HoqthuRONxKeGzMigHMh2 WC2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/L1RvZyZvCDXemlIoCq0cxdYfSW/Rg5Sx+S01P8nGHI=; b=cilUpoOlZ/7EBNbySGMtcy38Vo6rbQUpQ6Jb7QasT5nYMqaIhkTlMdLyzlth6vCm9c JU6LhBU64J2rCZSrNgiPkvAU12u3O5VGJ4zEq9alE0HI1zldPDb/XDGGVLExcNaD9QgT osVBbr5AYNWwUsvbkQvM9P3SOwpOJ7M8PFVWST/PTsWPLCaSQ8SDLtvU90qxzn715XZz +KQqZX48yKJ/DrhWA8j3QZtNXOgS7axVQh+eQJrDhkQNOtBD4zsvyfuGYQBRgpLIXeQQ ZmbzmsYhi0r8CNSupALmXfIHe2N38XY/hsxx2ZhtKUCIPwEQGvfNvil4pQZvKEDo/Y5r 3/yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mNRabWq6; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si5423693edd.539.2021.02.11.23.53.57; Thu, 11 Feb 2021 23:54:22 -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=@linuxfoundation.org header.s=korg header.b=mNRabWq6; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbhBLHxS (ORCPT + 99 others); Fri, 12 Feb 2021 02:53:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:46808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBLHxQ (ORCPT ); Fri, 12 Feb 2021 02:53:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E732F64E13; Fri, 12 Feb 2021 07:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613116356; bh=HpQHk0OqD+sZW6SvknIg2+jOr/x2orf6nVRPBzChn2A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mNRabWq6nE7HhAVGwLKpYDNptcxDLgLj4LcBHF2ySyfcVBC8SY4bF6fb2cMF7Ury+ z0HyrfWtG2HIDvcoIXstx5x/JRW2J9TjvrywenHeLsZWipcH6AKgSknfaWwwDl8VhG rnWLcHYucyQOsIl/Pxd3fNu7MwAeYyskImDcN67w= Date: Fri, 12 Feb 2021 08:52:33 +0100 From: Greg Kroah-Hartman To: shuo.a.liu@intel.com Cc: linux-next@vger.kernel.org, Stephen Rothwell , Randy Dunlap , linux-kernel@vger.kernel.org Subject: Re: [PATCH] virt: acrn: Fix vCPU removing code build error Message-ID: References: <20210212045724.77846-1-shuo.a.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210212045724.77846-1-shuo.a.liu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2021 at 12:57:24PM +0800, shuo.a.liu@intel.com wrote: > From: Shuo Liu > > vCPU removing code depends on CONFIG_HOTPLUG_CPU as it uses remove_cpu() > and add_cpu(). Make the vCPU removing interface building with > CONFIG_HOTPLUG_CPU. > > ../drivers/virt/acrn/hsm.c: In function ‘remove_cpu_store’: > ../drivers/virt/acrn/hsm.c:389:3: error: implicit declaration of function ‘remove_cpu’; [-Werror=implicit-function-declaration] > remove_cpu(cpu); > > ../drivers/virt/acrn/hsm.c:402:2: error: implicit declaration of function ‘add_cpu’; [-Werror=implicit-function-declaration] > add_cpu(cpu); > > Fixes: 279dcf693ac7 ("virt: acrn: Introduce an interface for Service VM to control vCPU") > Reported-by: Randy Dunlap > Acked-by: Randy Dunlap # build-tested > Signed-off-by: Shuo Liu > --- > drivers/virt/acrn/hsm.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/virt/acrn/hsm.c b/drivers/virt/acrn/hsm.c > index 1f6b7c54a1a4..e340788aacdf 100644 > --- a/drivers/virt/acrn/hsm.c > +++ b/drivers/virt/acrn/hsm.c > @@ -372,6 +372,7 @@ static int acrn_dev_release(struct inode *inode, struct file *filp) > return 0; > } > > +#ifdef CONFIG_HOTPLUG_CPU > static ssize_t remove_cpu_store(struct device *dev, > struct device_attribute *attr, > const char *buf, size_t count) > @@ -403,9 +404,12 @@ static ssize_t remove_cpu_store(struct device *dev, > return ret; > } > static DEVICE_ATTR_WO(remove_cpu); > +#endif > > static struct attribute *acrn_attrs[] = { > +#ifdef CONFIG_HOTPLUG_CPU > &dev_attr_remove_cpu.attr, > +#endif > NULL > }; > > Shouldn't the real solution for this be that remove_cpu() and add_cpu() have function prototypes for when this is not enabled in the kernel build? Putting #ifdef in .c files like this is not a good idea at all. Then, at runtime, you can determine if you need to create this sysfs file or not, as you do not want to expose it to userspace if the kernel can not handle it, right? thanks, greg k-h