All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	Stefano Stabellini <stefano.stabellini@citrix.com>,
	Tim Deegan <tim@xen.org>, Ian Campbell <ian.campbell@citrix.com>,
	xen-devel <xen-devel@lists.xen.org>
Subject: Re: [RFC PATCH v3 8/8] xen/arm: cpufreq: add xen-cpufreq driver
Date: Fri, 24 Oct 2014 12:29:43 +0100	[thread overview]
Message-ID: <544A3827.1010207@linaro.org> (raw)
In-Reply-To: <CAN58jisKtgEAmxq5w7fThUwYdbJf-xgPpqfa6Zq9vP_B_jsipw@mail.gmail.com>

Hi Oleksandr,

On 10/24/2014 11:38 AM, Oleksandr Dmytryshyn wrote:
> On Thu, Oct 23, 2014 at 7:03 PM, Julien Grall <julien.grall@linaro.org> wrote:
>> On 10/23/2014 04:08 PM, Oleksandr Dmytryshyn wrote:
>>> diff --git a/drivers/cpufreq/xen-cpufreq.c b/drivers/cpufreq/xen-cpufreq.c
>>> new file mode 100644
>>> index 0000000..a7f0977
>>> --- /dev/null
>>> +++ b/drivers/cpufreq/xen-cpufreq.c
>>> @@ -0,0 +1,889 @@
>>> +/*
>>> + *  Copyright (C) 2001 Russell King
>>> + *            (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
>>> + *
>>> + *  Oct 2005 - Ashok Raj <ashok.raj@intel.com>
>>> + *   Added handling for CPU hotplug
>>> + *  Feb 2006 - Jacob Shin <jacob.shin@amd.com>
>>> + *   Fix handling for CPU hotplug -- affected CPUs
>>> + *
>>> + *           (C) 2014 GlobalLogic Inc.
>>> + *
>>> + * Based on drivers/cpufreq/cpufreq.c
>>
>> It would be interesting to explain roughly what are the major changes
>> between drivers/cpufreq/cpufreq.c and this drivers.
> Here are some changes:
>  * I've introduced xen_nr_cpus which equals to real physical CPUs number
>    and xen-cpufreq.c uses it. Original driver cpufreq.c uses nr_cpu_ids -
>    virtual CPUs number.
>  * I've removed unused parts (sreating files in the sysfs, governors, etc)
>  * I've added xen-specific functions.
>  * If we have a separate file (xen-cpufreq.c) - it is possible to
>    use both drivers (cpufreq.c and xen-cpufreq.c) at the same time and
>    start compiled kernel under Xen and under bare metal without recompilation.

Can you add this in below "Base on ..."?

>>> + *
>>> + * This program is free software; you can redistribute it and/or modify it
>>> + * under the terms and conditions of the GNU General Public License,
>>> + * version 2, as published by the Free Software Foundation.
>>> + *
>>> + * This program is distributed in the hope it will be useful, but WITHOUT
>>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>>> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
>>> + * more details.
>>> + */
>>> +
>>> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>>> +
>>> +#include <linux/kernel.h>
>>> +#include <linux/module.h>
>>> +#include <linux/init.h>
>>> +#include <linux/notifier.h>
>>> +#include <linux/types.h>
>>> +#include <linux/slab.h>
>>> +#include <linux/mutex.h>
>>> +#include <linux/irq.h>
>>> +#include <linux/workqueue.h>
>>> +#include <linux/cpufreq.h>
>>> +
>>> +#include <trace/events/power.h>
>>> +
>>> +#include <xen/xen.h>
>>> +#include <xen/events.h>
>>> +#include <xen/interface/xen.h>
>>> +#include <xen/interface/platform.h>
>>> +#include <xen/interface/sysctl.h>
>>> +#include <asm/xen/hypercall.h>
>>> +
>>> +#include "cpufreq_drv_ops.h"
>>> +
>>> +#ifdef CONFIG_CPUMASK_OFFSTACK
>>> +#error CONFIG_CPUMASK_OFFSTACK config should not be used with this driver
>>> +#endif
> 
> 
>> I remembered we talk about this check on a previous version of this
>> patch. Can't we disable the option in Kconfig rather than throwing a
>> compilation error?
>>
>> Or maybe...
> I can just remove this checking from this file. But I'm afraid if this options
> will be turned on and CPUs bit mask will correspond to the virtual CPUs number
> instead of the NR_CPUS number. And in this case some functions (like
> cpumask_setall()) will work not correctly, because physical CPUs number can be
> greater then virtual CPUs number. May be Kconfig option CONFIG_XEN_CPUFREQ
> should be depend from !CONFIG_CPUMASK_OFFSTACK option? In this case
> this checking may be safely removed from this file.
> 
>>> +static int __init xen_cpufreq_init(void)
>>
>> [..]
> I'll fix this in the next patch set.
> 
>>> +     xen_nr_cpus = op.u.physinfo.nr_cpus;
>>> +     if (xen_nr_cpus == 0 || xen_nr_cpus > NR_CPUS) {
>>
>> Improving this check by also testing nr_cpumask_bits here.
> nr_cpumask_bits corresponds to the virtual CPUs number and it should be checked
> in the another place. This driver works only with physical CPUs.

AFAIU, nr_cpumask_bits is used to dynamically allocate the size of
cpumask_var_t.

It's possible to have a platform where the number of virtual CPUs is
equal to the number of physical CPUs (It's the default on Xen).

Anyway, it looks like this option can be only enabled when
DEBUG_PER_CPU_MAPS is set. The change in Kconfig looks like the best
solution for now.

Regards,

-- 
Julien Grall

  reply	other threads:[~2014-10-24 11:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23 15:08 [RFC PATCH v3 0/8] xen_cpufreq implementation in kernel Oleksandr Dmytryshyn
2014-10-23 15:08 ` [RFC PATCH v3 1/8] PM / OPP: make cpufreq functions dependent on CONFIG_CPU_FREQ_TABLE Oleksandr Dmytryshyn
2014-10-23 15:08 ` [RFC PATCH v3 2/8] xen/arm: implement HYPERVISOR_sysctl Oleksandr Dmytryshyn
2014-10-23 15:08 ` [RFC PATCH v3 3/8] xen/arm: implement HYPERVISOR_dom0_op Oleksandr Dmytryshyn
2014-10-23 15:08 ` [RFC PATCH v3 4/8] xen/arm: add XEN_SYSCTL_cpufreq_op definition Oleksandr Dmytryshyn
2014-10-23 15:08 ` [RFC PATCH v3 5/8] cpufreq: cpufreq-cpu0: change cpus data path in devtree for hwdom kernel Oleksandr Dmytryshyn
2014-10-23 15:08 ` [RFC PATCH v3 6/8] cpufreq: introduce cpufreq_drv_ops Oleksandr Dmytryshyn
2014-10-23 15:08 ` [RFC PATCH v3 7/8] cpufreq: make cpufreq low-level drivers visible for CPUFREQ_DRV_OPS config Oleksandr Dmytryshyn
2014-10-23 15:08 ` [RFC PATCH v3 8/8] xen/arm: cpufreq: add xen-cpufreq driver Oleksandr Dmytryshyn
2014-10-23 16:03   ` Julien Grall
2014-10-24 10:38     ` Oleksandr Dmytryshyn
2014-10-24 11:29       ` Julien Grall [this message]
2014-10-24 12:28         ` Oleksandr Dmytryshyn
2014-10-26 17:38 ` [RFC PATCH v3 0/8] xen_cpufreq implementation in kernel Stefano Stabellini
2014-11-04 13:07   ` Oleksandr Dmytryshyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=544A3827.1010207@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=oleksandr.dmytryshyn@globallogic.com \
    --cc=rjw@sisk.pl \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.