Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31E04C7EE33 for ; Tue, 28 Feb 2023 19:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbjB1TNP (ORCPT ); Tue, 28 Feb 2023 14:13:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjB1TNO (ORCPT ); Tue, 28 Feb 2023 14:13:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74E191D90C; Tue, 28 Feb 2023 11:13:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F139661181; Tue, 28 Feb 2023 19:13:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFD2EC433EF; Tue, 28 Feb 2023 19:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1677611591; bh=NomRgZhAnCadauaNPou4fifv4G+IJxYhxbkOJyVdeaY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gC9tn+qCRdX2PPavqpJdx8Gqi2XJrpEt/lxYjeSZMFH1MkwOPTnWeGZSSFyrivHHz y+G2Ujnzj5zWphHDQNoj18ubFP9kBGdM1QlEVrI/nK1xvmeQH5ySs/ol0TpkotjjJb /sP1lQwiBZp3nUCCxtQ1UZ3IMNi7g58hng+JOqyw= Date: Tue, 28 Feb 2023 11:13:10 -0800 From: Andrew Morton To: Jiri Olsa Cc: Alexei Starovoitov , Andrii Nakryiko , Hao Luo , Alexander Viro , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Matthew Wilcox , bpf@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Daniel Borkmann , Namhyung Kim Subject: Re: [PATCH RFC v2 bpf-next 1/9] mm: Store build id in inode object Message-Id: <20230228111310.05f339a0a1a00e919859ffad@linux-foundation.org> In-Reply-To: <20230228093206.821563-2-jolsa@kernel.org> References: <20230228093206.821563-1-jolsa@kernel.org> <20230228093206.821563-2-jolsa@kernel.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Feb 2023 10:31:58 +0100 Jiri Olsa wrote: > Storing build id in file's inode object for elf executable with build > id defined. The build id is stored when file is mmaped. > > This is enabled with new config option CONFIG_INODE_BUILD_ID. > > The build id is valid only when the file with given inode is mmap-ed. > > We store either the build id itself or the error we hit during > the retrieval. > > ... > > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -699,6 +700,12 @@ struct inode { > struct fsverity_info *i_verity_info; > #endif > > +#ifdef CONFIG_INODE_BUILD_ID > + /* Initialized and valid for executable elf files when mmap-ed. */ > + struct build_id *i_build_id; > + spinlock_t i_build_id_lock; > +#endif > + Remember we can have squillions of inodes in memory. So that's one costly spinlock! AFAICT this lock could be removed if mmap_region() were to use an atomic exchange on inode->i_build_id? If not, can we use an existing lock? i_lock would be appropriate (don't forget to update its comment). Also, the code in mmap_region() runs build_id_free() inside the locked region, which seems unnecessary.