From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=212.77.101.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794917528; b=T6Xp44515sR8mfG2YgrjnCuYXjQcrC7j+5wiOVDx86HofxXeLi0+nMZO8xZ6MJQ97FJk enURRxZU6JwzGR8c9/+e4JHeWkANj0jqDOg8CLqQHM12yvw0KRD5s2nR6YgvcPYd6g9Sn Sni9c5eFbKE3aFDolvkTv3dqqWHN+jI8sobWwrUAYvkpmmpPGOi7BbASHcvWcxNxGj+24 lx85kgmbgAeAKkwbg+3TwjayIy016CfKHLmPt1KXPdLUFhpNINhOOebXFLXZgVk4RVXtd VhZf8ZWQPIa1hx/lckCnqDIker4qHd3b7wAzO43/4Ab0vO6WDKVs49WG8POCtPC1ghQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794917528; h=DMARC-Filter:Received:DKIM-Signature:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:X-WP-MailID:X-WP-AV:X-WP-SPAM; bh=lj9OagPSRJNvuPdGLWpYCPjIPPY/8eEyHeaFsrygvcA=; b=tYW88A3w72HX49Z3K+A/40iu64B2jkJmaBmvoOXSKhi3J4Y0foQzCOt1Mlw9X+41Pmy5 fHbuqWWZ8eHacu9h44SXxDUCgwjqSSGszsruukhMjMsx4C+KDG4BbjiDBGOL4fySFCZHH W7VrJv3esVTn4Q7P51NsAu2OlSq5GYbtaEN2bSSAGUDGG7zLwn+WcXQtdSlYsciwLoQnc 0d0tG0JXUVS1sQKOsJ8umG5ScC6uo+wy2+IVc+LT0nvWp30jAZBL1ouCFsb4j9hJYdQlp eu2WaWr3bM/GqKQi7fMc7cuKhvBLjqdwI/r5svpS3Ac2buu3NqfLLZ3OyPad63iGSGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=wp.pl; spf=pass smtp.mailfrom=wp.pl; dkim=pass header.d=wp.pl header.i=@wp.pl header.a=rsa-sha256 header.s=s20261001 header.b=jlgRi2Cz; arc=none smtp.remote-ip=212.77.101.11 Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14444606A32C for ; Tue, 17 Nov 2026 12:12:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 14444606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wp.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.a=rsa-sha256 header.s=s20261001 header.b=jlgRi2Cz Received: (wp-smtpd smtp.wp.pl 8210 invoked from network); 17 Nov 2026 13:12:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=s20261001; t=1794917525; bh=lj9OagPSRJNvuPdGLWpYCPjIPPY/8eEyHeaFsrygvcA=; h=From:To:Cc:Subject; b=jlgRi2Cz/vVIwgREakUwVS49sHWLB7aN7h7CfhjIj8hgRoJdvFDpuemdEJaaQWwiy dv6H+g5JUTUe7bna0U+ZEuLGGD3ivvaHT5aYkCLA37aVE0naYwhKWc+fMGMbJqvn4n OY3PoxhoDsCkSAYYOx9wcabMT+LCqb6fRUmuLcF0bgz7bhUcmZa39D2UcyEuFwKdBj gnKIWHao6SFiQh4sbj97f1n7eF9nY1RfajMxe/2eXHHo4MfMt0g85h6FC4grEYgvBz +MT/z8JqAEQJ7MKF8RGMb5Rb7h/bmkkGJjN+aLVkyklihZhinWd3LFhUgRN4GYKugV GP2gKmLvNH+aw== Received: from localhost (77-236-5-223.static.play.pl [77.236.5.223]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with TLS_AES_256_GCM_SHA384 encrypted SMTP for ; 17 Nov 2026 13:12:05 +0100 Date: Tue, 17 Nov 2026 13:12:04 +0100 From: Stanislaw Gruszka To: Petr Mladek Cc: linux-modules@vger.kernel.org, Sami Tolvanen , Luis Chamberlain , Petr Pavlu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, live-patching@vger.kernel.org, Daniel Gomez , Aaron Tomlin , Steven Rostedt , Masami Hiramatsu , Jordan Rome , Viktor Malik , Miroslav Benes , Josh Poimboeuf , Joe Lawrence Subject: Re: [PATCH v2 2/2] module/kallsyms: sort function symbols and use binary search Message-ID: References: <20260327110005.16499-1-stf_xl@wp.pl> <20260327110005.16499-2-stf_xl@wp.pl> X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-WP-MailID: 53ea68bc8316ef981b297076ee5d6f3b X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 000000A [sTNU] Hi On Tue, May 05, 2026 at 02:24:41PM +0200, Petr Mladek wrote: > 2. Livepatches _rely on the sorting_ of symbols in the module. > The special relocation symbols might define a symbol position, > see > > .klp.sym.objname.symbol_name,sympos > > in the documentation. It defines the position of the symbol > when there are more symbols of the same name, see > klp_match_callback() in kernel/livepatch/core.c. > > I am afraid that _this patch might break_ this when it moves > function symbols before non-funciton ones. I guess that > the symbols of the same name will not longer be groupped. Thanks for pointing this out. It took me quite a while to understand the issue, but I finally got it. > Idea: Is the shufling really important for the performance, please? One reason I wanted to shuffle the symbols was to also speed up name-based lookups, assuming that most lookups are for function symbols. Moving them to the beginning of the table reduces the number of entries that need to be scanned in the common case. In my benchmarks, this reduced the average time spent in __find_kallsyms_symbol_value() from 16 us to 6 us. > I would expect that binary search would have a good performance > even without the shuffling. It puts aside half of the symbols in > one cycle. I'm now going with a separate sorted index table, leaving the original symtab untouched. I think the name lookup optimization could be revisited later by introducing a new function that uses the index table to search only text symbols, where appropriate. Regards Stanislaw