Re: [PATCH 5.15.y] ACPI: processor_idle: Fix invalid comparison with insertion sort for latency

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

 



On Tue, Jul 16, 2024 at 11:30:31PM +0800, Kuan-Wei Chiu wrote:
> The acpi_cst_latency_cmp() comparison function currently used for
> sorting C-state latencies does not satisfy transitivity, causing
> incorrect sorting results.
> 
> Specifically, if there are two valid acpi_processor_cx elements A and B
> and one invalid element C, it may occur that A < B, A = C, and B = C.
> Sorting algorithms assume that if A < B and A = C, then C < B, leading
> to incorrect ordering.
> 
> Given the small size of the array (<=8), we replace the library sort
> function with a simple insertion sort that properly ignores invalid
> elements and sorts valid ones based on latency. This change ensures
> correct ordering of the C-state latencies.
> 
> Fixes: 65ea8f2c6e23 ("ACPI: processor idle: Fix up C-state latency if not ordered")
> Reported-by: Julian Sikorski <belegdol@xxxxxxxxx>
> Closes: https://lore.kernel.org/lkml/70674dc7-5586-4183-8953-8095567e73df@xxxxxxxxx
> Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
> Tested-by: Julian Sikorski <belegdol@xxxxxxxxx>
> Cc: All applicable <stable@xxxxxxxxxxxxxxx>
> Link: https://patch.msgid.link/20240701205639.117194-1-visitorckw@xxxxxxxxx
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> (cherry picked from commit 233323f9b9f828cd7cd5145ad811c1990b692542)
> Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
> ---
>  drivers/acpi/processor_idle.c | 40 ++++++++++++++---------------------
>  1 file changed, 16 insertions(+), 24 deletions(-)

ALl now queued up, thanks.

greg k-h




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux