Message ID | 20240320105529.5626-1-lihuisong@huawei.com (mailing list archive) |
---|---|
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 24CB443CFF; Wed, 20 Mar 2024 12:02:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 106E9402A2; Wed, 20 Mar 2024 12:02:45 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 61DDC40298 for <dev@dpdk.org>; Wed, 20 Mar 2024 12:02:43 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V05GJ0Zhgz1h2qW; Wed, 20 Mar 2024 19:00:08 +0800 (CST) Received: from kwepemm600004.china.huawei.com (unknown [7.193.23.242]) by mail.maildlp.com (Postfix) with ESMTPS id 4EB19140411; Wed, 20 Mar 2024 19:02:41 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 20 Mar 2024 19:02:40 +0800 From: Huisong Li <lihuisong@huawei.com> To: <dev@dpdk.org> CC: <thomas@monjalon.net>, <ferruh.yigit@amd.com>, <anatoly.burakov@intel.com>, <david.hunt@intel.com>, <sivaprasad.tummala@amd.com>, <liuyonglong@huawei.com>, <lihuisong@huawei.com> Subject: [PATCH 0/2] introduce PM QoS interface Date: Wed, 20 Mar 2024 18:55:27 +0800 Message-ID: <20240320105529.5626-1-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600004.china.huawei.com (7.193.23.242) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org |
Series |
introduce PM QoS interface
|
|
Message
lihuisong (C)
March 20, 2024, 10:55 a.m. UTC
Subject: [PATCH 0/2] introduce PM QoS interface The system-wide CPU latency QoS limit has a positive impact on the idle state selection in cpuidle governor. Linux creates a cpu_dma_latency device under '/dev' directory to obtain the CPU latency QoS limit on system and send the QoS request for userspace. Please see the PM QoS framework in the following link: https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos This feature is supported by kernel-v2.6.25. The deeper the idle state, the lower the power consumption, but the longer the resume time. Some service are delay sensitive and very except the low resume time, like interrupt packet receiving mode. So this series introduce PM QoS interface. Huisong Li (2): power: introduce PM QoS interface examples/l3fwd-power: add PM QoS request configuration doc/guides/prog_guide/power_man.rst | 16 ++++ doc/guides/rel_notes/release_24_03.rst | 4 + examples/l3fwd-power/main.c | 41 +++++++++- lib/power/meson.build | 2 + lib/power/rte_power_qos.c | 98 ++++++++++++++++++++++++ lib/power/rte_power_qos.h | 101 +++++++++++++++++++++++++ lib/power/version.map | 4 + 7 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 lib/power/rte_power_qos.c create mode 100644 lib/power/rte_power_qos.h
Comments
> From: Huisong Li [mailto:lihuisong@huawei.com] > Sent: Wednesday, 20 March 2024 11.55 > > The system-wide CPU latency QoS limit has a positive impact on the idle > state selection in cpuidle governor. > > Linux creates a cpu_dma_latency device under '/dev' directory to obtain the > CPU latency QoS limit on system and send the QoS request for userspace. > Please see the PM QoS framework in the following link: > https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos > This feature is supported by kernel-v2.6.25. > > The deeper the idle state, the lower the power consumption, but the longer > the resume time. Some service are delay sensitive and very except the low > resume time, like interrupt packet receiving mode. > > So this series introduce PM QoS interface. This looks like a 1:1 wrapper for a Linux kernel feature. Does Windows or BSD offer something similar? Furthermore, any high-res timing should use nanoseconds, not microseconds or milliseconds. I realize that the Linux kernel only uses microseconds for these APIs, but the DPDK API should use nanoseconds.
Hi Moren, Thanks for your revew. 在 2024/3/20 22:05, Morten Brørup 写道: >> From: Huisong Li [mailto:lihuisong@huawei.com] >> Sent: Wednesday, 20 March 2024 11.55 >> >> The system-wide CPU latency QoS limit has a positive impact on the idle >> state selection in cpuidle governor. >> >> Linux creates a cpu_dma_latency device under '/dev' directory to obtain the >> CPU latency QoS limit on system and send the QoS request for userspace. >> Please see the PM QoS framework in the following link: >> https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos >> This feature is supported by kernel-v2.6.25. >> >> The deeper the idle state, the lower the power consumption, but the longer >> the resume time. Some service are delay sensitive and very except the low >> resume time, like interrupt packet receiving mode. >> >> So this series introduce PM QoS interface. > This looks like a 1:1 wrapper for a Linux kernel feature. right > Does Windows or BSD offer something similar? How do we know Windows or BSD support this similar feature? The DPDK power lib just work on Linux according to the meson.build under lib/power. If they support this features, they can open it. > > Furthermore, any high-res timing should use nanoseconds, not microseconds or milliseconds. > I realize that the Linux kernel only uses microseconds for these APIs, but the DPDK API should use nanoseconds. Nanoseconds is more precise, it's good. But DPDK API how use nanoseconds as you said the the Linux kernel only uses microseconds for these APIs. Kernel interface just know an integer value with microseconds unit. /BR /Huisong
> From: lihuisong (C) [mailto:lihuisong@huawei.com] > Sent: Thursday, 21 March 2024 04.04 > > Hi Moren, > > Thanks for your revew. > > 在 2024/3/20 22:05, Morten Brørup 写道: > >> From: Huisong Li [mailto:lihuisong@huawei.com] > >> Sent: Wednesday, 20 March 2024 11.55 > >> > >> The system-wide CPU latency QoS limit has a positive impact on the idle > >> state selection in cpuidle governor. > >> > >> Linux creates a cpu_dma_latency device under '/dev' directory to obtain the > >> CPU latency QoS limit on system and send the QoS request for userspace. > >> Please see the PM QoS framework in the following link: > >> https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos > >> This feature is supported by kernel-v2.6.25. > >> > >> The deeper the idle state, the lower the power consumption, but the longer > >> the resume time. Some service are delay sensitive and very except the low > >> resume time, like interrupt packet receiving mode. > >> > >> So this series introduce PM QoS interface. > > This looks like a 1:1 wrapper for a Linux kernel feature. > right > > Does Windows or BSD offer something similar? > How do we know Windows or BSD support this similar feature? Ask Windows experts or research using Google. > The DPDK power lib just work on Linux according to the meson.build under > lib/power. > If they support this features, they can open it. The DPDK power lib currently only works on Linux, yes. But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future. DPDK is on track to work across multiple platforms, including Windows. We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only. > > > > Furthermore, any high-res timing should use nanoseconds, not microseconds or > milliseconds. > > I realize that the Linux kernel only uses microseconds for these APIs, but > the DPDK API should use nanoseconds. > Nanoseconds is more precise, it's good. > But DPDK API how use nanoseconds as you said the the Linux kernel only > uses microseconds for these APIs. > Kernel interface just know an integer value with microseconds unit. One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds. You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution.
+Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows. 在 2024/3/21 21:30, Morten Brørup 写道: >> From: lihuisong (C) [mailto:lihuisong@huawei.com] >> Sent: Thursday, 21 March 2024 04.04 >> >> Hi Moren, >> >> Thanks for your revew. >> >> 在 2024/3/20 22:05, Morten Brørup 写道: >>>> From: Huisong Li [mailto:lihuisong@huawei.com] >>>> Sent: Wednesday, 20 March 2024 11.55 >>>> >>>> The system-wide CPU latency QoS limit has a positive impact on the idle >>>> state selection in cpuidle governor. >>>> >>>> Linux creates a cpu_dma_latency device under '/dev' directory to obtain the >>>> CPU latency QoS limit on system and send the QoS request for userspace. >>>> Please see the PM QoS framework in the following link: >>>> https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos >>>> This feature is supported by kernel-v2.6.25. >>>> >>>> The deeper the idle state, the lower the power consumption, but the longer >>>> the resume time. Some service are delay sensitive and very except the low >>>> resume time, like interrupt packet receiving mode. >>>> >>>> So this series introduce PM QoS interface. >>> This looks like a 1:1 wrapper for a Linux kernel feature. >> right >>> Does Windows or BSD offer something similar? >> How do we know Windows or BSD support this similar feature? > Ask Windows experts or research using Google. I download freebsd source code, I didn't find this similar feature. They don't even support cpuidle feature(this QoS feature affects cpuilde.). I don't find any useful about this on Windows from google. @Tyler, @Alan, @Wei and @Long Do you know windows support that userspace read and send CPU latency which has an impact on deep level of CPU idle? >> The DPDK power lib just work on Linux according to the meson.build under >> lib/power. >> If they support this features, they can open it. > The DPDK power lib currently only works on Linux, yes. > But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future. > > DPDK is on track to work across multiple platforms, including Windows. > We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only. totally understand you. > >>> Furthermore, any high-res timing should use nanoseconds, not microseconds or >> milliseconds. >>> I realize that the Linux kernel only uses microseconds for these APIs, but >> the DPDK API should use nanoseconds. >> Nanoseconds is more precise, it's good. >> But DPDK API how use nanoseconds as you said the the Linux kernel only >> uses microseconds for these APIs. >> Kernel interface just know an integer value with microseconds unit. > One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds. If so, we have to modify the implementation interface on Linux. This change the input/output unit about the interface. And DPDK also has to do this based on kernel version. It is not good. The cpuidle governor select which idle state based on the worst-case latency of idle state. These the worst-case latency of Cstate reported by ACPI table is in microseconds as the section 8.4.1.1. _CST (C States) and 8.4.3.3. _LPI (Low Power Idle States) in ACPI spec [1]. So it is probably not meaning to change this interface implementation. For the case need PM QoS in DPDK, I think, it is better to set cpu latency to zero to prevent service thread from the deeper the idle state. > You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution. > [1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
> From: lihuisong (C) [mailto:lihuisong@huawei.com] > Sent: Friday, 22 March 2024 09.54 > > +Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows. > > 在 2024/3/21 21:30, Morten Brørup 写道: > >> From: lihuisong (C) [mailto:lihuisong@huawei.com] > >> Sent: Thursday, 21 March 2024 04.04 > >> > >> Hi Moren, > >> > >> Thanks for your revew. > >> > >> 在 2024/3/20 22:05, Morten Brørup 写道: > >>>> From: Huisong Li [mailto:lihuisong@huawei.com] > >>>> Sent: Wednesday, 20 March 2024 11.55 > >>>> > >>>> The system-wide CPU latency QoS limit has a positive impact on the idle > >>>> state selection in cpuidle governor. > >>>> > >>>> Linux creates a cpu_dma_latency device under '/dev' directory to obtain > the > >>>> CPU latency QoS limit on system and send the QoS request for userspace. > >>>> Please see the PM QoS framework in the following link: > >>>> https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos > >>>> This feature is supported by kernel-v2.6.25. > >>>> > >>>> The deeper the idle state, the lower the power consumption, but the > longer > >>>> the resume time. Some service are delay sensitive and very except the low > >>>> resume time, like interrupt packet receiving mode. > >>>> > >>>> So this series introduce PM QoS interface. > >>> This looks like a 1:1 wrapper for a Linux kernel feature. > >> right > >>> Does Windows or BSD offer something similar? > >> How do we know Windows or BSD support this similar feature? > > Ask Windows experts or research using Google. > I download freebsd source code, I didn't find this similar feature. > They don't even support cpuidle feature(this QoS feature affects cpuilde.). > I don't find any useful about this on Windows from google. > > > @Tyler, @Alan, @Wei and @Long > > Do you know windows support that userspace read and send CPU latency > which has an impact on deep level of CPU idle? > > >> The DPDK power lib just work on Linux according to the meson.build under > >> lib/power. > >> If they support this features, they can open it. > > The DPDK power lib currently only works on Linux, yes. > > But its API should still be designed to be platform agnostic, so the > functions can be implemented on other platforms in the future. > > > > DPDK is on track to work across multiple platforms, including Windows. > > We must always consider other platforms, and not design DPDK APIs as if they > are for Linux/BSD only. > totally understand you. > > > >>> Furthermore, any high-res timing should use nanoseconds, not microseconds > or > >> milliseconds. > >>> I realize that the Linux kernel only uses microseconds for these APIs, but > >> the DPDK API should use nanoseconds. > >> Nanoseconds is more precise, it's good. > >> But DPDK API how use nanoseconds as you said the the Linux kernel only > >> uses microseconds for these APIs. > >> Kernel interface just know an integer value with microseconds unit. > > One solution is to expose nanoseconds in the DPDK API, and in the Linux > specific implementation convert from/to microseconds. > If so, we have to modify the implementation interface on Linux. This > change the input/output unit about the interface. > And DPDK also has to do this based on kernel version. It is not good. > The cpuidle governor select which idle state based on the worst-case > latency of idle state. > These the worst-case latency of Cstate reported by ACPI table is in > microseconds as the section 8.4.1.1. _CST (C States) and 8.4.3.3. _LPI > (Low Power Idle States) in ACPI spec [1]. > So it is probably not meaning to change this interface implementation. OK... Since microsecond resolution is good enough for ACPI and Linux, you have me convinced that it's also good enough for DPDK (for this specific topic). Thank you for the detailed reply! > > For the case need PM QoS in DPDK, I think, it is better to set cpu > latency to zero to prevent service thread from the deeper the idle state. It would defeat the purpose (i.e. not saving sufficient amounts of power) if the CPU cannot enter a deeper idle state. Personally, I would think a wake-up latency of up to 10 microseconds should be fine for must purposes. Default Linux timerslack is 50 microseconds, so you could also use that value. > > You might also want to add a note to the in-line documentation of the > relevant functions that the Linux implementation only uses microsecond > resolution. > > > [1] > https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
On Fri, Mar 22, 2024 at 04:54:01PM +0800, lihuisong (C) wrote: > +Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows. > > 在 2024/3/21 21:30, Morten Brørup 写道: > >>From: lihuisong (C) [mailto:lihuisong@huawei.com] > >>Sent: Thursday, 21 March 2024 04.04 > >> > >>Hi Moren, > >> > >>Thanks for your revew. > >> > >>在 2024/3/20 22:05, Morten Brørup 写道: > >>>>From: Huisong Li [mailto:lihuisong@huawei.com] > >>>>Sent: Wednesday, 20 March 2024 11.55 > >>>> > >>>>The system-wide CPU latency QoS limit has a positive impact on the idle > >>>>state selection in cpuidle governor. > >>>> > >>>>Linux creates a cpu_dma_latency device under '/dev' directory to obtain the > >>>>CPU latency QoS limit on system and send the QoS request for userspace. > >>>>Please see the PM QoS framework in the following link: > >>>>https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos > >>>>This feature is supported by kernel-v2.6.25. > >>>> > >>>>The deeper the idle state, the lower the power consumption, but the longer > >>>>the resume time. Some service are delay sensitive and very except the low > >>>>resume time, like interrupt packet receiving mode. > >>>> > >>>>So this series introduce PM QoS interface. > >>>This looks like a 1:1 wrapper for a Linux kernel feature. > >>right > >>>Does Windows or BSD offer something similar? > >>How do we know Windows or BSD support this similar feature? > >Ask Windows experts or research using Google. > I download freebsd source code, I didn't find this similar feature. > They don't even support cpuidle feature(this QoS feature affects cpuilde.). > I don't find any useful about this on Windows from google. > > > @Tyler, @Alan, @Wei and @Long > > Do you know windows support that userspace read and send CPU latency > which has an impact on deep level of CPU idle? it is unlikely you'll find an api that let's you manage things in terms of raw latency values as the linux knobs here do. windows more often employs policy centric schemes to permit the system to abstract implementation detail. powercfg is probably the closest thing you can use to tune the same things on windows. where you select e.g. the 'performance' scheme but it won't allow you to pick specific latency numbers. https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/powercfg-command-line-options > > >>The DPDK power lib just work on Linux according to the meson.build under > >>lib/power. > >>If they support this features, they can open it. > >The DPDK power lib currently only works on Linux, yes. > >But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future. > > > >DPDK is on track to work across multiple platforms, including Windows. > >We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only. > totally understand you. since lib/power isn't built for windows at this time i don't think it's appropriate to constrain your innovation. i do appreciate the engagement though and would just offer general guidance that if you can design your api with some kind of abstraction in mind that would be great and by all means if you can figure out how to wrangle powercfg /Qh into satisfying the api in a policy centric way it might be kind of nice. i'll let other windows experts chime in here if they choose. thanks! > > > >>>Furthermore, any high-res timing should use nanoseconds, not microseconds or > >>milliseconds. > >>>I realize that the Linux kernel only uses microseconds for these APIs, but > >>the DPDK API should use nanoseconds. > >>Nanoseconds is more precise, it's good. > >>But DPDK API how use nanoseconds as you said the the Linux kernel only > >>uses microseconds for these APIs. > >>Kernel interface just know an integer value with microseconds unit. > >One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds. > If so, we have to modify the implementation interface on Linux. This > change the input/output unit about the interface. > And DPDK also has to do this based on kernel version. It is not good. > The cpuidle governor select which idle state based on the worst-case > latency of idle state. > These the worst-case latency of Cstate reported by ACPI table is in > microseconds as the section 8.4.1.1. _CST (C States) and 8.4.3.3. > _LPI (Low Power Idle States) in ACPI spec [1]. > So it is probably not meaning to change this interface implementation. > > For the case need PM QoS in DPDK, I think, it is better to set cpu > latency to zero to prevent service thread from the deeper the idle > state. > >You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution. > > > [1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
在 2024/3/22 20:35, Morten Brørup 写道: >> From: lihuisong (C) [mailto:lihuisong@huawei.com] >> Sent: Friday, 22 March 2024 09.54 >> >> +Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows. >> >> 在 2024/3/21 21:30, Morten Brørup 写道: >>>> From: lihuisong (C) [mailto:lihuisong@huawei.com] >>>> Sent: Thursday, 21 March 2024 04.04 >>>> >>>> Hi Moren, >>>> >>>> Thanks for your revew. >>>> >>>> 在 2024/3/20 22:05, Morten Brørup 写道: >>>>>> From: Huisong Li [mailto:lihuisong@huawei.com] >>>>>> Sent: Wednesday, 20 March 2024 11.55 >>>>>> >>>>>> The system-wide CPU latency QoS limit has a positive impact on the idle >>>>>> state selection in cpuidle governor. >>>>>> >>>>>> Linux creates a cpu_dma_latency device under '/dev' directory to obtain >> the >>>>>> CPU latency QoS limit on system and send the QoS request for userspace. >>>>>> Please see the PM QoS framework in the following link: >>>>>> https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos >>>>>> This feature is supported by kernel-v2.6.25. >>>>>> >>>>>> The deeper the idle state, the lower the power consumption, but the >> longer >>>>>> the resume time. Some service are delay sensitive and very except the low >>>>>> resume time, like interrupt packet receiving mode. >>>>>> >>>>>> So this series introduce PM QoS interface. >>>>> This looks like a 1:1 wrapper for a Linux kernel feature. >>>> right >>>>> Does Windows or BSD offer something similar? >>>> How do we know Windows or BSD support this similar feature? >>> Ask Windows experts or research using Google. >> I download freebsd source code, I didn't find this similar feature. >> They don't even support cpuidle feature(this QoS feature affects cpuilde.). >> I don't find any useful about this on Windows from google. >> >> >> @Tyler, @Alan, @Wei and @Long >> >> Do you know windows support that userspace read and send CPU latency >> which has an impact on deep level of CPU idle? >> >>>> The DPDK power lib just work on Linux according to the meson.build under >>>> lib/power. >>>> If they support this features, they can open it. >>> The DPDK power lib currently only works on Linux, yes. >>> But its API should still be designed to be platform agnostic, so the >> functions can be implemented on other platforms in the future. >>> DPDK is on track to work across multiple platforms, including Windows. >>> We must always consider other platforms, and not design DPDK APIs as if they >> are for Linux/BSD only. >> totally understand you. >>>>> Furthermore, any high-res timing should use nanoseconds, not microseconds >> or >>>> milliseconds. >>>>> I realize that the Linux kernel only uses microseconds for these APIs, but >>>> the DPDK API should use nanoseconds. >>>> Nanoseconds is more precise, it's good. >>>> But DPDK API how use nanoseconds as you said the the Linux kernel only >>>> uses microseconds for these APIs. >>>> Kernel interface just know an integer value with microseconds unit. >>> One solution is to expose nanoseconds in the DPDK API, and in the Linux >> specific implementation convert from/to microseconds. >> If so, we have to modify the implementation interface on Linux. This >> change the input/output unit about the interface. >> And DPDK also has to do this based on kernel version. It is not good. >> The cpuidle governor select which idle state based on the worst-case >> latency of idle state. >> These the worst-case latency of Cstate reported by ACPI table is in >> microseconds as the section 8.4.1.1. _CST (C States) and 8.4.3.3. _LPI >> (Low Power Idle States) in ACPI spec [1]. >> So it is probably not meaning to change this interface implementation. > OK... Since microsecond resolution is good enough for ACPI and Linux, you have me convinced that it's also good enough for DPDK (for this specific topic). > > Thank you for the detailed reply! > >> For the case need PM QoS in DPDK, I think, it is better to set cpu >> latency to zero to prevent service thread from the deeper the idle state. > It would defeat the purpose (i.e. not saving sufficient amounts of power) if the CPU cannot enter a deeper idle state. Yes, it is not good for power. AFAIS, PM QoS is just to decrease the influence for performance. Anyway, if we set to zero, system can be into Cstates-0 at least. > > Personally, I would think a wake-up latency of up to 10 microseconds should be fine for must purposes. > Default Linux timerslack is 50 microseconds, so you could also use that value. How much CPU latency is ok. Maybe, we can give the decision to the application. Linux will collect all these QoS request and use the minimum latency. what do you think, Morten? > >>> You might also want to add a note to the in-line documentation of the >> relevant functions that the Linux implementation only uses microsecond >> resolution. >> [1] >> https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html
Hi Tyler, 在 2024/3/23 1:55, Tyler Retzlaff 写道: > On Fri, Mar 22, 2024 at 04:54:01PM +0800, lihuisong (C) wrote: >> +Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows. >> >> 在 2024/3/21 21:30, Morten Brørup 写道: >>>> From: lihuisong (C) [mailto:lihuisong@huawei.com] >>>> Sent: Thursday, 21 March 2024 04.04 >>>> >>>> Hi Moren, >>>> >>>> Thanks for your revew. >>>> >>>> 在 2024/3/20 22:05, Morten Brørup 写道: >>>>>> From: Huisong Li [mailto:lihuisong@huawei.com] >>>>>> Sent: Wednesday, 20 March 2024 11.55 >>>>>> >>>>>> The system-wide CPU latency QoS limit has a positive impact on the idle >>>>>> state selection in cpuidle governor. >>>>>> >>>>>> Linux creates a cpu_dma_latency device under '/dev' directory to obtain the >>>>>> CPU latency QoS limit on system and send the QoS request for userspace. >>>>>> Please see the PM QoS framework in the following link: >>>>>> https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos >>>>>> This feature is supported by kernel-v2.6.25. >>>>>> >>>>>> The deeper the idle state, the lower the power consumption, but the longer >>>>>> the resume time. Some service are delay sensitive and very except the low >>>>>> resume time, like interrupt packet receiving mode. >>>>>> >>>>>> So this series introduce PM QoS interface. >>>>> This looks like a 1:1 wrapper for a Linux kernel feature. >>>> right >>>>> Does Windows or BSD offer something similar? >>>> How do we know Windows or BSD support this similar feature? >>> Ask Windows experts or research using Google. >> I download freebsd source code, I didn't find this similar feature. >> They don't even support cpuidle feature(this QoS feature affects cpuilde.). >> I don't find any useful about this on Windows from google. >> >> >> @Tyler, @Alan, @Wei and @Long >> >> Do you know windows support that userspace read and send CPU latency >> which has an impact on deep level of CPU idle? > it is unlikely you'll find an api that let's you manage things in terms > of raw latency values as the linux knobs here do. windows more often employs > policy centric schemes to permit the system to abstract implementation detail. > > powercfg is probably the closest thing you can use to tune the same > things on windows. where you select e.g. the 'performance' scheme but it > won't allow you to pick specific latency numbers. > > https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/powercfg-command-line-options Thanks for your feedback. I will take a look at this tool. > >>>> The DPDK power lib just work on Linux according to the meson.build under >>>> lib/power. >>>> If they support this features, they can open it. >>> The DPDK power lib currently only works on Linux, yes. >>> But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future. >>> >>> DPDK is on track to work across multiple platforms, including Windows. >>> We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only. >> totally understand you. > since lib/power isn't built for windows at this time i don't think it's > appropriate to constrain your innovation. i do appreciate the engagement > though and would just offer general guidance that if you can design your > api with some kind of abstraction in mind that would be great and by all > means if you can figure out how to wrangle powercfg /Qh into satisfying the > api in a policy centric way it might be kind of nice. Testing this by using powercfg on Windows creates a very challenge for me. So I don't plan to do this on Windows. If you need, you can add it, ok? > > i'll let other windows experts chime in here if they choose. > > thanks! > >>>>> Furthermore, any high-res timing should use nanoseconds, not microseconds or >>>> milliseconds. >>>>> I realize that the Linux kernel only uses microseconds for these APIs, but >>>> the DPDK API should use nanoseconds. >>>> Nanoseconds is more precise, it's good. >>>> But DPDK API how use nanoseconds as you said the the Linux kernel only >>>> uses microseconds for these APIs. >>>> Kernel interface just know an integer value with microseconds unit. >>> One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds. >> If so, we have to modify the implementation interface on Linux. This >> change the input/output unit about the interface. >> And DPDK also has to do this based on kernel version. It is not good. >> The cpuidle governor select which idle state based on the worst-case >> latency of idle state. >> These the worst-case latency of Cstate reported by ACPI table is in >> microseconds as the section 8.4.1.1. _CST (C States) and 8.4.3.3. >> _LPI (Low Power Idle States) in ACPI spec [1]. >> So it is probably not meaning to change this interface implementation. >> >> For the case need PM QoS in DPDK, I think, it is better to set cpu >> latency to zero to prevent service thread from the deeper the idle >> state. >>> You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution. >>> >> [1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html > .
> From: lihuisong (C) [mailto:lihuisong@huawei.com] > Sent: Tuesday, 26 March 2024 03.12 > > 在 2024/3/22 20:35, Morten Brørup 写道: > >> From: lihuisong (C) [mailto:lihuisong@huawei.com] > >> Sent: Friday, 22 March 2024 09.54 [...] > >> For the case need PM QoS in DPDK, I think, it is better to set cpu > >> latency to zero to prevent service thread from the deeper the idle > state. > > It would defeat the purpose (i.e. not saving sufficient amounts of > power) if the CPU cannot enter a deeper idle state. > Yes, it is not good for power. > AFAIS, PM QoS is just to decrease the influence for performance. > Anyway, if we set to zero, system can be into Cstates-0 at least. > > > > Personally, I would think a wake-up latency of up to 10 microseconds > should be fine for must purposes. > > Default Linux timerslack is 50 microseconds, so you could also use > that value. > How much CPU latency is ok. Maybe, we can give the decision to the > application. Yes, the application should decide the acceptable worst-case latency. > Linux will collect all these QoS request and use the minimum latency. > what do you think, Morten? For the example application, you could use a value of 50 microseconds and refer to this value also being the default timerslack in Linux.
在 2024/3/26 16:27, Morten Brørup 写道: >> From: lihuisong (C) [mailto:lihuisong@huawei.com] >> Sent: Tuesday, 26 March 2024 03.12 >> >> 在 2024/3/22 20:35, Morten Brørup 写道: >>>> From: lihuisong (C) [mailto:lihuisong@huawei.com] >>>> Sent: Friday, 22 March 2024 09.54 > [...] > >>>> For the case need PM QoS in DPDK, I think, it is better to set cpu >>>> latency to zero to prevent service thread from the deeper the idle >> state. >>> It would defeat the purpose (i.e. not saving sufficient amounts of >> power) if the CPU cannot enter a deeper idle state. >> Yes, it is not good for power. >> AFAIS, PM QoS is just to decrease the influence for performance. >> Anyway, if we set to zero, system can be into Cstates-0 at least. >>> Personally, I would think a wake-up latency of up to 10 microseconds >> should be fine for must purposes. >>> Default Linux timerslack is 50 microseconds, so you could also use >> that value. >> How much CPU latency is ok. Maybe, we can give the decision to the >> application. > Yes, the application should decide the acceptable worst-case latency. > >> Linux will collect all these QoS request and use the minimum latency. >> what do you think, Morten? > For the example application, you could use a value of 50 microseconds and refer to this value also being the default timerslack in Linux. There is a description for "/proc/<pid>/timerslack_ns" in Linux document [1] " This file provides the value of the task’s timerslack value in nanoseconds. This value specifies an amount of time that normal timers may be deferred in order to coalesce timers and avoid unnecessary wakeups. This allows a task’s interactivity vs power consumption tradeoff to be adjusted. " I cannot understand what the relationship is between the timerslack in Linux and cpu latency to wake up. It seems that timerslack is just to defer the timer in order to coalesce timers and avoid unnecessary wakeups. And it has not a lot to do with the CPU latency which is aimed to avoid task to enter deeper idle state and satify application request. >
> From: lihuisong (C) [mailto:lihuisong@huawei.com] > Sent: Tuesday, 26 March 2024 13.15 > > 在 2024/3/26 16:27, Morten Brørup 写道: > >> From: lihuisong (C) [mailto:lihuisong@huawei.com] > >> Sent: Tuesday, 26 March 2024 03.12 > >> > >> 在 2024/3/22 20:35, Morten Brørup 写道: > >>>> From: lihuisong (C) [mailto:lihuisong@huawei.com] > >>>> Sent: Friday, 22 March 2024 09.54 > > [...] > > > >>>> For the case need PM QoS in DPDK, I think, it is better to set cpu > >>>> latency to zero to prevent service thread from the deeper the idle > >> state. > >>> It would defeat the purpose (i.e. not saving sufficient amounts of > >> power) if the CPU cannot enter a deeper idle state. > >> Yes, it is not good for power. > >> AFAIS, PM QoS is just to decrease the influence for performance. > >> Anyway, if we set to zero, system can be into Cstates-0 at least. > >>> Personally, I would think a wake-up latency of up to 10 microseconds > >> should be fine for must purposes. > >>> Default Linux timerslack is 50 microseconds, so you could also use > >> that value. > >> How much CPU latency is ok. Maybe, we can give the decision to the > >> application. > > Yes, the application should decide the acceptable worst-case latency. > > > >> Linux will collect all these QoS request and use the minimum latency. > >> what do you think, Morten? > > For the example application, you could use a value of 50 microseconds > and refer to this value also being the default timerslack in Linux. > There is a description for "/proc/<pid>/timerslack_ns" in Linux document > [1] > " > This file provides the value of the task’s timerslack value in > nanoseconds. > This value specifies an amount of time that normal timers may be > deferred in order to coalesce timers and avoid unnecessary wakeups. > This allows a task’s interactivity vs power consumption tradeoff to be > adjusted. > " > I cannot understand what the relationship is between the timerslack in > Linux and cpu latency to wake up. > It seems that timerslack is just to defer the timer in order to coalesce > timers and avoid unnecessary wakeups. > And it has not a lot to do with the CPU latency which is aimed to avoid > task to enter deeper idle state and satify application request. Correct. They control two different things. However, both can cause latency for the application, so my rationale for the relationship was: If the application accepts X us of latency caused by kernel scheduling delays (caused by timerslack), the application should accept the same amount of latency caused by CPU wake-up latency. This also means that if you want lower latency than 50 us, you should not only set cpu wake-up latency, you should also set timerslack. Obviously, if the application is only affected by one of the two, the application only needs to adjust that one of them. As for the 50 us value, someone in the Linux kernel team decided that 50 us was an acceptable amount of latency for the kernel; we could use the same value, referring to that. Or we could choose some other value, and describe how we came up with our own value. And if necessary, also adjust timerslack accordingly.
On Tue, Mar 26, 2024 at 10:20:45AM +0800, lihuisong (C) wrote: > Hi Tyler, > > 在 2024/3/23 1:55, Tyler Retzlaff 写道: > >On Fri, Mar 22, 2024 at 04:54:01PM +0800, lihuisong (C) wrote: > >>+Tyler, +Alan, +Wei, +Long for asking this similar feature on Windows. > >> > >>在 2024/3/21 21:30, Morten Brørup 写道: > >>>>From: lihuisong (C) [mailto:lihuisong@huawei.com] > >>>>Sent: Thursday, 21 March 2024 04.04 > >>>> > >>>>Hi Moren, > >>>> > >>>>Thanks for your revew. > >>>> > >>>>在 2024/3/20 22:05, Morten Brørup 写道: > >>>>>>From: Huisong Li [mailto:lihuisong@huawei.com] > >>>>>>Sent: Wednesday, 20 March 2024 11.55 > >>>>>> > >>>>>>The system-wide CPU latency QoS limit has a positive impact on the idle > >>>>>>state selection in cpuidle governor. > >>>>>> > >>>>>>Linux creates a cpu_dma_latency device under '/dev' directory to obtain the > >>>>>>CPU latency QoS limit on system and send the QoS request for userspace. > >>>>>>Please see the PM QoS framework in the following link: > >>>>>>https://docs.kernel.org/power/pm_qos_interface.html?highlight=qos > >>>>>>This feature is supported by kernel-v2.6.25. > >>>>>> > >>>>>>The deeper the idle state, the lower the power consumption, but the longer > >>>>>>the resume time. Some service are delay sensitive and very except the low > >>>>>>resume time, like interrupt packet receiving mode. > >>>>>> > >>>>>>So this series introduce PM QoS interface. > >>>>>This looks like a 1:1 wrapper for a Linux kernel feature. > >>>>right > >>>>>Does Windows or BSD offer something similar? > >>>>How do we know Windows or BSD support this similar feature? > >>>Ask Windows experts or research using Google. > >>I download freebsd source code, I didn't find this similar feature. > >>They don't even support cpuidle feature(this QoS feature affects cpuilde.). > >>I don't find any useful about this on Windows from google. > >> > >> > >>@Tyler, @Alan, @Wei and @Long > >> > >>Do you know windows support that userspace read and send CPU latency > >>which has an impact on deep level of CPU idle? > >it is unlikely you'll find an api that let's you manage things in terms > >of raw latency values as the linux knobs here do. windows more often employs > >policy centric schemes to permit the system to abstract implementation detail. > > > >powercfg is probably the closest thing you can use to tune the same > >things on windows. where you select e.g. the 'performance' scheme but it > >won't allow you to pick specific latency numbers. > > > >https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/powercfg-command-line-options > > Thanks for your feedback. I will take a look at this tool. > > > > >>>>The DPDK power lib just work on Linux according to the meson.build under > >>>>lib/power. > >>>>If they support this features, they can open it. > >>>The DPDK power lib currently only works on Linux, yes. > >>>But its API should still be designed to be platform agnostic, so the functions can be implemented on other platforms in the future. > >>> > >>>DPDK is on track to work across multiple platforms, including Windows. > >>>We must always consider other platforms, and not design DPDK APIs as if they are for Linux/BSD only. > >>totally understand you. > >since lib/power isn't built for windows at this time i don't think it's > >appropriate to constrain your innovation. i do appreciate the engagement > >though and would just offer general guidance that if you can design your > >api with some kind of abstraction in mind that would be great and by all > >means if you can figure out how to wrangle powercfg /Qh into satisfying the > >api in a policy centric way it might be kind of nice. > Testing this by using powercfg on Windows creates a very challenge for me. > So I don't plan to do this on Windows. If you need, you can add it, ok? ordinarily i would say it is appropriate to, however in this circumstance i agree. there is quite possibly significant porting work to be done so i would have to address it if we ever include it for windows. thanks > > > >i'll let other windows experts chime in here if they choose. > > > >thanks! > > > >>>>>Furthermore, any high-res timing should use nanoseconds, not microseconds or > >>>>milliseconds. > >>>>>I realize that the Linux kernel only uses microseconds for these APIs, but > >>>>the DPDK API should use nanoseconds. > >>>>Nanoseconds is more precise, it's good. > >>>>But DPDK API how use nanoseconds as you said the the Linux kernel only > >>>>uses microseconds for these APIs. > >>>>Kernel interface just know an integer value with microseconds unit. > >>>One solution is to expose nanoseconds in the DPDK API, and in the Linux specific implementation convert from/to microseconds. > >>If so, we have to modify the implementation interface on Linux. This > >>change the input/output unit about the interface. > >>And DPDK also has to do this based on kernel version. It is not good. > >>The cpuidle governor select which idle state based on the worst-case > >>latency of idle state. > >>These the worst-case latency of Cstate reported by ACPI table is in > >>microseconds as the section 8.4.1.1. _CST (C States) and 8.4.3.3. > >>_LPI (Low Power Idle States) in ACPI spec [1]. > >>So it is probably not meaning to change this interface implementation. > >> > >>For the case need PM QoS in DPDK, I think, it is better to set cpu > >>latency to zero to prevent service thread from the deeper the idle > >>state. > >>>You might also want to add a note to the in-line documentation of the relevant functions that the Linux implementation only uses microsecond resolution. > >>> > >>[1] https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html > >.
在 2024/3/26 20:46, Morten Brørup 写道: >> From: lihuisong (C) [mailto:lihuisong@huawei.com] >> Sent: Tuesday, 26 March 2024 13.15 >> >> 在 2024/3/26 16:27, Morten Brørup 写道: >>>> From: lihuisong (C) [mailto:lihuisong@huawei.com] >>>> Sent: Tuesday, 26 March 2024 03.12 >>>> >>>> 在 2024/3/22 20:35, Morten Brørup 写道: >>>>>> From: lihuisong (C) [mailto:lihuisong@huawei.com] >>>>>> Sent: Friday, 22 March 2024 09.54 >>> [...] >>> >>>>>> For the case need PM QoS in DPDK, I think, it is better to set cpu >>>>>> latency to zero to prevent service thread from the deeper the idle >>>> state. >>>>> It would defeat the purpose (i.e. not saving sufficient amounts of >>>> power) if the CPU cannot enter a deeper idle state. >>>> Yes, it is not good for power. >>>> AFAIS, PM QoS is just to decrease the influence for performance. >>>> Anyway, if we set to zero, system can be into Cstates-0 at least. >>>>> Personally, I would think a wake-up latency of up to 10 microseconds >>>> should be fine for must purposes. >>>>> Default Linux timerslack is 50 microseconds, so you could also use >>>> that value. >>>> How much CPU latency is ok. Maybe, we can give the decision to the >>>> application. >>> Yes, the application should decide the acceptable worst-case latency. >>> >>>> Linux will collect all these QoS request and use the minimum latency. >>>> what do you think, Morten? >>> For the example application, you could use a value of 50 microseconds >> and refer to this value also being the default timerslack in Linux. >> There is a description for "/proc/<pid>/timerslack_ns" in Linux document >> [1] >> " >> This file provides the value of the task’s timerslack value in >> nanoseconds. >> This value specifies an amount of time that normal timers may be >> deferred in order to coalesce timers and avoid unnecessary wakeups. >> This allows a task’s interactivity vs power consumption tradeoff to be >> adjusted. >> " >> I cannot understand what the relationship is between the timerslack in >> Linux and cpu latency to wake up. >> It seems that timerslack is just to defer the timer in order to coalesce >> timers and avoid unnecessary wakeups. >> And it has not a lot to do with the CPU latency which is aimed to avoid >> task to enter deeper idle state and satify application request. > Correct. They control two different things. > > However, both can cause latency for the application, so my rationale for the relationship was: > If the application accepts X us of latency caused by kernel scheduling delays (caused by timerslack), the application should accept the same amount of latency caused by CPU wake-up latency. Understand, thanks for explain. > > This also means that if you want lower latency than 50 us, you should not only set cpu wake-up latency, you should also set timerslack. > > Obviously, if the application is only affected by one of the two, the application only needs to adjust that one of them. Yes, I think it is. > > As for the 50 us value, someone in the Linux kernel team decided that 50 us was an acceptable amount of latency for the kernel; we could use the same value, referring to that. Or we could choose some other value, and describe how we came up with our own value. And if necessary, also adjust timerslack accordingly. So how about use the default 50us of timerslack in l3fwd-power? And we add some description about this in code or document, like, suggest user also need to modify this process's timerslack if want a more little latency. >