[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 06/15] cpufreq: Add Hardware P-State (HWP) driver


  • To: Jason Andryuk <jandryuk@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 25 Jul 2023 16:37:35 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e0H5zcfSPg6NMySGaHQY8YOf1VikXtEJGncfYPRtJN4=; b=c3jkQNOkl7nKzuME7jQ30mK+NeQPjZHRTjOS6LwBK7TUrunrEy0c5skrSXfkVUWzq2RgCg760t9CmkuSggNa0OV3EMcyOhMd+7qHixaY6kVOhiM2jczEXt2LjKwQ5ZbyaIx657ZLENGYvnsjbLh6Mvrx2POL4tO3XvQ8486VLCjPSkZryr0dR1v8dnhpsMnJl/NLk6ewcnO3xVtyBApFcQP+FnqpOYl6eezZXsRYMTwGsteErstBxnUp7kKsUmxBex4MGcy0tPc62hfdVWI4bm/UJ+6xlpQW3viId1Ske7d7GIZsC3ZiLoBJm4CfeGn9cIIDhnSaZ1ftVNvG5gNxWg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F2bP0Fjt/8fOdptKzADti/3jypXtci+A2YMjK3r6e+x7hBjxH0NQ9U55PbVtinqKcxQFuhr9mGbib7rjsum0KnM1CJ6HlpjU0zA56XwiMczEofujtuTsjumzro3MVaaLYqwagNvEo0Gyvmmmd2iK5P11GfqIg6fHA+VmV3SgFoZ+oY3sPc10c6+WXKjJKwsR+poe2Mt9ZP9bzTvyuVrh7tRd7KOXJygdF5Tok4cqiVVgZA7cu3y6GmYzGNtDucLZ6WCHJPx9RpZ/ziJxw6qcW8zPv9XuAHd+qXbKFYMr6eBSxqWkFXk2t7uavtwfpPUW9qAm3sBPrgiYSKDpP9pONw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 25 Jul 2023 14:37:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25.07.2023 15:26, Jason Andryuk wrote:
> On Tue, Jul 25, 2023 at 2:27 AM Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>
>> On 24.07.2023 21:49, Jason Andryuk wrote:
>>> On Mon, Jul 24, 2023 at 12:15 PM Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>>> On 24.07.2023 14:58, Jason Andryuk wrote:
>>>>> --- /dev/null
>>>>> +++ b/xen/arch/x86/acpi/cpufreq/hwp.c
>>>>> +#define hwp_err(cpu, fmt, ...) \
>>>>> +    printk(XENLOG_ERR "HWP: CPU%u error: " fmt, cpu, ##__VA_ARGS__)
>>>>> +#define hwp_info(fmt, ...)    printk(XENLOG_INFO "HWP: " fmt, 
>>>>> ##__VA_ARGS__)
>>>>
>>>> I'm not convinced ", ##__VA_ARGS__" is a good construct to use. I notice
>>>> we have a few instances (mainly in code inherited from elsewhere), but I
>>>> think it ought to either be plain C99 style (without the ##) or purely
>>>> the gcc extension form (not using __VA_ARGS__).
>>>
>>> Using plain __VA_ARGS__ doesn't work for the cases without arguments:
>>> arch/x86/acpi/cpufreq/hwp.c:78:53: error: expected expression before ‘)’ 
>>> token
>>>    78 |         printk(XENLOG_DEBUG "HWP: " fmt, __VA_ARGS__);  \
>>>       |                                                     ^
>>> arch/x86/acpi/cpufreq/hwp.c:201:9: note: in expansion of macro ‘hwp_verbose’
>>>   201 |         hwp_verbose("disabled: No energy/performance
>>> preference available");
>>>       |         ^~~~~~~~~~~
>>
>> Of course.
>>
>>> I can use "__VA_OPT__(,) __VA_ARGS__" though.
>>
>> __VA_OPT__ is yet newer than C99, so this is an option only if all
>> compilers we continue to support actually know of this.
> 
> Right, sorry.
> 
>> We have no
>> uses of it in the codebase so far, which suggests you might best go
>> with the longstanding gcc extension here.
> 
> FTAOD, "##__VA_ARGS__" is the longstanding extension?

No. But you've apparently found it ...

>  It's the only
> one I've been able to get to compile.  I'm reading
> https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html and it
> mentions a few different extensions.
> 
> This part seemed promising:
> """
> This has been fixed in C++20, and GNU CPP also has a pair of
> extensions which deal with this problem.
> 
> First, in GNU CPP, and in C++ beginning in C++20, you are allowed to
> leave the variable argument out entirely:
> 
> eprintf ("success!\n")
>      → fprintf(stderr, "success!\n", );
> """
> 
> However, it doesn't seem to actually work for me.  I still get an
> error like the one above for plain __VA_ARGS__.  That is for:
> 
>     #define hwp_err(cpu, fmt, args...) \
>         printk(XENLOG_ERR "HWP: CPU%u error: " fmt, cpu, args)

..., just that you're missing the ##:

    #define hwp_err(cpu, fmt, args...) \
        printk(XENLOG_ERR "HWP: CPU%u error: " fmt, cpu, ## args)

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.