From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A24438B7C3 for ; Wed, 22 Jul 2026 02:38:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784687892; cv=none; b=ftpB3p+qrxqgJk4D4gwJYZmc7cIgGZVafse5hgOj4UnQuL4+cDLu7KI2+ZwJXFGFfY2uO/HRI/Y0CWE0I6RedoOg+8UA9tq7U68bN4aHDhCBTYx5mtmYMdppe/9LUj7z7F7gOKDNdQS5tKxvC552wWH5ryt7vCXToIKCD2O/Q4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784687892; c=relaxed/simple; bh=4DyyJbipMEPACZ2LD/I923Gcn9JElwaTtLTVtkRNdnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pboe5mFUJFwnBcAbKlgrG8UsLugnapFujgC31OSEwvFRq6pUMfL/0jWi7R6bT5zwe4wvL2QW5/1SDPPOeYPnTKs28oaUFubTxq7i4kvLdr+vc4ZkOiyIIkL5u8QL3LFH88dC6CGhAZBylmJyfvhKT7cqhlTa/UyIqxIqn/0SvfY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=VVDNMvrE; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="VVDNMvrE" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784687884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0NUjMF0YZdO+mWLr8nRUv6rJ891UqYSF7C3pZ4ivN0E=; b=VVDNMvrEWyE7yjD8VHyqPTE218LHSp/o3tlLxXnwLFcrWDr8PSVimr33+t6AbU9t8LchoV NcsJ7rO7SDQzCexd2Pbh0y7mstQoQWk7TancWsh9Aa1JIxXfGuQ3j32xERl45wpsUN1Jy4 ycZlfdJci8mU4zZ/iNRr1AUedWK/fJU= From: Ye Liu To: Andrew Morton Cc: Ye Liu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] tools/mm/page_owner_sort: fix --sort option being silently ignored Date: Wed, 22 Jul 2026 10:37:24 +0800 Message-Id: <20260722023726.600200-2-ye.liu@linux.dev> In-Reply-To: <20260722023726.600200-1-ye.liu@linux.dev> References: <20260722023726.600200-1-ye.liu@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Ye Liu When --sort is used without any short option (-a, -m, -p, etc.), compare_flag remains COMP_NO_FLAG. The switch (compare_flag) then falls through to the COMP_NUM case and calls set_single_cmp(), which unconditionally overwrites the sort conditions that parse_sort_args() already configured. This makes --sort silently ineffective unless a short option is also supplied. Split COMP_NO_FLAG out of the COMP_NUM fallthrough so that --sort is respected when no short option is present. Reproduction: # Before fix: ascending order (ignored --sort=-pid) ./page_owner_sort --sort=-pid input.txt output.txt # After fix: descending order as expected Signed-off-by: Ye Liu --- tools/mm/page_owner_sort.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c index 35d3d254941c..3c86c8d0618c 100644 --- a/tools/mm/page_owner_sort.c +++ b/tools/mm/page_owner_sort.c @@ -821,6 +821,10 @@ int main(int argc, char **argv) set_single_cmp(compare_stacktrace, SORT_ASC); break; case COMP_NO_FLAG: + if (sc.size > 0) + break; + set_single_cmp(compare_num, SORT_DESC); + break; case COMP_NUM: set_single_cmp(compare_num, SORT_DESC); break; -- 2.25.1