Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: stable@vger.kernel.org, Julian Sikorski <belegdol@gmail.com>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH 5.15.y] ACPI: processor_idle: Fix invalid comparison with insertion sort for latency
Date: Tue, 23 Jul 2024 15:19:52 +0200	[thread overview]
Message-ID: <2024072342-oblivion-stucco-3808@gregkh> (raw)
In-Reply-To: <20240716153031.159989-1-visitorckw@gmail.com>

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@gmail.com>
> Closes: https://lore.kernel.org/lkml/70674dc7-5586-4183-8953-8095567e73df@gmail.com
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> Tested-by: Julian Sikorski <belegdol@gmail.com>
> Cc: All applicable <stable@vger.kernel.org>
> Link: https://patch.msgid.link/20240701205639.117194-1-visitorckw@gmail.com
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> (cherry picked from commit 233323f9b9f828cd7cd5145ad811c1990b692542)
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> ---
>  drivers/acpi/processor_idle.c | 40 ++++++++++++++---------------------
>  1 file changed, 16 insertions(+), 24 deletions(-)

ALl now queued up, thanks.

greg k-h

  reply	other threads:[~2024-07-23 13:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 11:28 FAILED: patch "[PATCH] ACPI: processor_idle: Fix invalid comparison with insertion" failed to apply to 5.15-stable tree gregkh
2024-07-16 15:30 ` [PATCH 5.15.y] ACPI: processor_idle: Fix invalid comparison with insertion sort for latency Kuan-Wei Chiu
2024-07-23 13:19   ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-07-16 15:29 Kuan-Wei Chiu
2024-07-16 15:50 ` Kuan-Wei Chiu

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=2024072342-oblivion-stucco-3808@gregkh \
    --to=greg@kroah.com \
    --cc=belegdol@gmail.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=visitorckw@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox