From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795641932; b=jRx4Js0cfi6xRXRw1LBJ//ghGE1TSyk9KPJP+UlgVEkGYcxj/wXIDNLpPjtfrpZe9F4Q +bC0gcz5Ye6X7dXFqWPrgcfdgzJsp2xkNkoe7pEjfxG4F+eo84W6kBgOF6hxGDrWr9QLC 6AFY4qLkWbYJNWJwy6NgIlgQH9EFDQtJS+VIRGOxvvvQ9xuVPZatwtKw1oW2py00Ns7xb oQXXP9YUG3eYaqV+ZLfoFbcsfScvBD4TL2eyyfgH8a+t19JPZuNaPb9JoncMqmwrxclqc MoeGvJgXTAmQ1Vi2XRFeRc//migvQGd89PC3RxFwuqcQJKl+kkR4IUd7sWbG1w39T8Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795641932; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=24/tAy177JKP0owGUloJsJ9O1cxGKyGsp+3cRmkz8Hw=; b=Ki5Dxbzchhr7GnwbVED9KSzk3GxnkygXq7FQfEExDoOEJiKxoPr7OxnXDsojowcrw/Kh QxR0WtZrEcowHFyKGMHFBY3Sl51Px/TGpfh/OBFFkTaiZjcWxuHiXt88Q/beQyWvKwDKV vfqUT06Fe+tRqpxHnmzq2lXdU6wo8mj0ALOPBbPfetV4Ik0eUX0iaCKYgoQpfU51GV+RB j9VWb559bfRp9SnF0vB+nqOYc7K6d70ONqgMRo6sA5kcVZQS0CU1VqQxiQO18ZZWolou8 iAcdHOl924eyA3WKkQtlVBOGpJNldEGOgFqrNLc17p3ugExH+LlF9qo7Pmu05TAr3rQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=RI0PEVo8; arc=none smtp.remote-ip=209.85.128.45 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A24F6606A32E for ; Wed, 25 Nov 2026 21:25:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A24F6606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=RI0PEVo8 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4bb85e07aadso78050235e9.1 for ; Wed, 25 Nov 2026 13:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795641930; x=1796246730; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=24/tAy177JKP0owGUloJsJ9O1cxGKyGsp+3cRmkz8Hw=; b=RI0PEVo8e/bM5LpLPZ+ED0hsyThViRRY4VFXcvOC3yq8ssab9D3GWTn/NExxaMUXZ/ SCEfAUzxIznLHW4X8Ux3FmsnGjVl8+Tu2I50vFro4UF290hC+aOGoCx3seQbB/Kkai92 i2zbpMXrHM1e+hdoZw3s9g8KJwVNLFn1XzFiXMwhZLLCZapmock/E0+9J3LFHctwNKM2 1wJUObs/t1OyGzg2ZnBNFqAphLTJMLH8yCwqrFBvoaxKN25zrCKYmaShH0vjh09I3jpG Uz4nqzrg6/yfBT6SdKciD9tyk2az1dmjbdzWK08Rn0x/RK7kdBz6as33XNA2CJWx8x3B BHwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795641930; x=1796246730; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=24/tAy177JKP0owGUloJsJ9O1cxGKyGsp+3cRmkz8Hw=; b=WBYBbrFzb50K3wGoUxYYWjc/I8P8n7fzTIEvh8dU9ira4GEgRLGcOzWInyrZYi/7NY NpqVrQZ3Q55EZFQLKcdgJaD3fWCXmF8syzVJlZJtAL4gGBLCcvrEpoxv+zlGdM+eMCWF VtdJIcsrn6HnwWr3wkZnPFEuBHa8rwb74GtKXuDfySHosqnFGKIHD/0Yj5bQp6/0EcD2 OQV/uE38PRdZUn+C1w5I5j7zSun967verUjxq4Dt5Ge3xJw17zhvIwEPr9leC+ntya6g U3yhrH/LqzrMQGU/cHS01VyXQPktke2ISgfefdg/BVTGZwrYqDTB10PEPl1HPbJK3ufO Kk4A== X-Forwarded-Encrypted: i=1; AL+hErHFYGoXJgAzPW1LSBwSQFyVEDNuVpoEyYxObJTpmcekft42N/g4SEfqoFFbrZouBtUVMyAgQjPFoySJFrk=@vger.kernel.org X-Gm-Message-State: APuU4Z+ZBkl12UUpN2vxPzD1QIOwtruRZ3wIyvp/2+OGFi02gUODpHP0 kUekALQ7kryw2BwYGN8LkOTQzmci9eNAFxa1hePKUYmdBRH/agWe9GNc X-Gm-Gg: AZFdTZcHwHVl6u/XsHJue4e6NN12UAuCgTt78Y08JKS8AVL/NiEB3xdYN5APGoAGW6g jW5x+kRHRqyc9bMgZ9pVtMvf89O1gPbk2WimKXu0W+G2V/vCaleUxx/qPIi0Hj2HXBqp+9k5v7Y XWgGnaJwwmcQRAzerycCyWK2//KN2xgy2kuGBPSnXrL0kntglyIJoQZOb7MZPjeMmvwhlLKsxdS +iWKA3KmyquEz6wQsn4NCaseneOmdMBbYOhiqUxwHSk1wWdwIckjI3KBVCQrUGZ6psZhOoRzUN4 aM3051oH8WAzGyRRivqZtxXHRC4GqZi3Ghqj27MtP11iJKXlKu6GduHG1EuiI2aKqiXzrtT7exe mxPInX/z68bmm3gSUFwLW1Z2aMgjqv8i2mZCCjYmfKvNV/IJFIVtzZK0EM8FeAkDkZ10uvmmtoI u/8rAMI17t4vFMLtDBaBsFwNVKKIOCMqkMVu2AvKLJc0t49uAohWIlR06ALFW3zR5xh40QSNngJ jkjr6vp4kHoFruGFOZunnt1fL/b0v74kGHoAonPG4KNxsk8XbyQiixJDuKeILrSj3ulvJd7tHLI sGDkw5YybMgkg8NcMtsc18p5B80KmMVLqGjUQe/HENKx0qx3I4lvCgW8iTnIvQzJmw== X-Received: by 2002:a05:600c:4584:b0:4bb:5de1:e90f with SMTP id 5b1f17b1804b1-4bb88819bcdmr380720815e9.31.1795641929874; Wed, 25 Nov 2026 13:25:29 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853c9170sm615777065e9.14.2026.11.25.13.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 13:25:29 -0800 (PST) Date: Wed, 25 Nov 2026 21:25:28 +0000 From: David Laight To: Petr Pavlu Cc: Samuel Wu , Jonathan Corbet , Shuah Khan , Randy Dunlap , Luis Chamberlain , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Alexander Viro , Christian Brauner , Jan Kara , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andrew Morton , Petr Mladek , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-modules@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH bpf-next v3 2/9] module: Add module_kallsyms_find_name() Message-ID: <20261125212528.239ab6bf@pumpkin> In-Reply-To: <0c2e606e-e0b8-4466-b9dd-4db14cc35d1d@suse.com> References: <20261113221248.3535369-11-wusamuel@google.com> <20261113221248.3535369-13-wusamuel@google.com> <0c2e606e-e0b8-4466-b9dd-4db14cc35d1d@suse.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) X-Mailing-List: linux-kernel@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-Transfer-Encoding: 7bit On Wed, 25 Nov 2026 17:45:36 +0100 Petr Pavlu wrote: > On 11/13/26 11:12 PM, Samuel Wu wrote: > > KALLSYMS_QUERY_BY_NAME, added later in this series, needs to find a > > symbol name or prefix across module symbols in one pass. > > module_get_kallsym() walks the module list from the head and runs an > > export bsearch() for every symbol index. > > > > Add module_kallsyms_find_name(), and put the shared query struct in > > linux/kallsyms.h, so we have a more efficient linear walk. > > > > Signed-off-by: Samuel Wu > > --- > > [...] > > diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c > > index 1ff8ce857d92..72006c9bad42 100644 > > --- a/kernel/module/kallsyms.c > > +++ b/kernel/module/kallsyms.c > > @@ -406,6 +406,63 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, > > return -ERANGE; > > } > > > > +/** > > + * module_kallsyms_find_name - Find a module symbol by name or prefix > > + * @symnum: in: index to start at; out: index of the match. The index > > + * counts the symbols of the searched modules in list order. > > + * @q: name query; if @q->modname is set, only that module is searched > > + * @value: set to the symbol address > > + * @name: set to the symbol name (KSYM_NAME_LEN bytes) > > + * @module_name: set to the module name (MODULE_NAME_LEN bytes) > > + * > > + * Undefined (SHN_UNDEF) symbols are skipped. > > + * > > + * Return: 0 on a match, or -ENOENT. > > + */ > > +int module_kallsyms_find_name(unsigned int *symnum, > > + const struct kallsyms_name_query *q, > > + unsigned long *value, char *name, > > + char *module_name) > > Nit: kernel/module/kallsyms.c already contains a zoo of lookup functions > with similar names. Adding module_kallsyms_find_name() adds more to the > confusion, being similar to module_kallsyms_lookup_name() and > find_kallsyms_symbol_value(). I've thought of splitting the file in two. Separating the core symbol table functions from the /proc/kallsyms code. Might help here as well. The cut goes just above the extra structure the /proc code uses. Three functions have to be made non-static, none are that internal. David > > I suggest calling it module_kallsyms_query_name() to match the > kallsyms_name_query parameter and to express that this is a structured > query, as opposed to a simple by-name lookup. It might be a good idea to > similarly stick to "query" instead of "find" in kernel/kallsyms.c. > > Otherwise, this looks ok to me from the modules perspective. Feel free > to add: > > Reviewed-by: Petr Pavlu >