From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BA18C52D71 for ; Thu, 8 Aug 2024 18:33:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D63AF6B008A; Thu, 8 Aug 2024 14:33:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D13946B008C; Thu, 8 Aug 2024 14:33:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C01D26B0093; Thu, 8 Aug 2024 14:33:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A208E6B008A for ; Thu, 8 Aug 2024 14:33:43 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4E8641C4C07 for ; Thu, 8 Aug 2024 18:33:43 +0000 (UTC) X-FDA: 82429926726.10.0B147D7 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) by imf20.hostedemail.com (Postfix) with ESMTP id D0F761C0039 for ; Thu, 8 Aug 2024 18:33:39 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=CkzykHs6; spf=pass (imf20.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.189 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723141954; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9gHGOt9FPEl0EXI7QFx2sNXwvm3rxL5jF8Uqu3Gc0K8=; b=Ow2vd5axVk8yu3NZHu2IDkV2/MJMLPweY1/XWhNOKVDR3pt9TePX1XBTFScPRv9Om7bODd mWTcKBVB4/wVcVQ3v/tARJMoF0JW9P7171qpg9W5mZiXlsQsUhu4tY6NVGopPTWJ/5GBaP vwTTzhlIe5PS3xnPRm971ZccQkUsUYA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723141954; a=rsa-sha256; cv=none; b=wXQpTcFCzQjZPM1gh56cWJK9JgmCP3eBX37kNIdhPdzrbvFOgUemu0/YlqNHpCTChIpJ2v wncGxZYukxYtUFICe3sbwMNgvN4GN4mjBFSq7m0f4vy1Y0ezXz8svU5b0nbseIdtZYLYay itf10LzxgKMj2wQ9RZxvqCVmOKnNUTE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=CkzykHs6; spf=pass (imf20.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.189 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Thu, 8 Aug 2024 11:33:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1723142017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9gHGOt9FPEl0EXI7QFx2sNXwvm3rxL5jF8Uqu3Gc0K8=; b=CkzykHs69r4gMuFTUMVsIjvjHD/xTZKFmY4YYjQuaMvOCCmONbMKp0H/38gSyY1UDEHdAG 7oPYaN2grWwvOTVjXU0U/7jEqhhrBGHOBqjlAwyS24DPik/2mfS0+ZIEhiazzAETcUH1l3 fYlvLmt3dgG0TCBVkz/S+f5ZoZmeJE4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Andrii Nakryiko Cc: bpf@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, adobriyan@gmail.com, hannes@cmpxchg.org, ak@linux.intel.com, osandov@osandov.com, song@kernel.org, jannh@google.com, linux-fsdevel@vger.kernel.org, willy@infradead.org Subject: Re: [PATCH v4 bpf-next 02/10] lib/buildid: add single folio-based file reader abstraction Message-ID: References: <20240807234029.456316-1-andrii@kernel.org> <20240807234029.456316-3-andrii@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240807234029.456316-3-andrii@kernel.org> X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 5wfskd6hioxa4nr1p7cgwfpndibsw6y7 X-Rspamd-Queue-Id: D0F761C0039 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723142019-60990 X-HE-Meta: U2FsdGVkX1+ZIAYZ8ywzEV/2wZUg03xWI6/wvM/6Y7zDHFkunz3ZsgvxHAB9Nu0OBIPRsnnssFwK6n30aY/iTiGSNH0dV+gr/5Yc2JfPLWnkQdbPE9nq8xV8+Kwp5HhXg7DFJitcrvOmHdbVWpLsBiirrv7YNpoR0MMsrLYyjjgwqLuwIHcpXraRB+a15JpBxCKRmlxzvge3ta7UxV5CEauNfNsJy8KuAdognuCYA74lhtXbue9WJEoi6wzfOEncVtGJw8JstB3pzCTf2KRwQPxZo3Mpg85C9hBvJljyS6GZHdw94HCOf692q8qpxGbOiTtEgkGjxuJ9Iq55U1O6Bsx1wErcW8h+DUdwdzaNQ3k4oi2MGsQy2hwz2YX5rZgUZjPPmu2iyYxQg7LiaZino76lLTS8CTFzlxJV1Gs2RGdXBq1BppnyTh6l9C5Dlclxg0m3mHRxO7pgswhHZX7RIq95qrlN0Ak0AygiOTqRI1U77borj7JSya5wWch378+qDgswJfasaV/W0yzuZY75cLjHp6CRl9s45kxnUheG6EMyl5h4PM7sgKGwYHuSu0osZcp73WM1KopPGnYMKTf07Z0zwFuvg0R1cffOAj0aOELVVDGDLzoOFa+OZIgMWL/f9YCKr+D1tZ5pqZZhKLpfwCHN4tNbJ9hBOSIoL6PRLWYwCTYuj8VkJrIpINRT29ZwdPNOyBq93VFenN5//lTVPWIXvXK7hBYFO5FD62X+atWIT6rOVKYPvIIfVfPk3tjwgCVnN+0tHgr8ZZ9KIyXB7I+uhUf6NoWcVkBTKowL96I8MEA1DKYz+uwztmVndJ+lIJhKY86xPB5q/oVFfn6d5+PPOhkKRAqhUfZAw+Z46lAEIFIEA7Jx88NMAbKERp5pPcuf5MqBwoJiklP+fV3cyGnw8BsOnqkm0zVMOk9lHMnMG9DGi9NEqSOoFJgIAXxTq7x62y73y3N6wX3lryo nFGT+03y Fqr9O6QGe2zlWwgIKnlFsPRaObjw3W2k98O8xPfnxdPc6ACgFrA/l+XEG30ruBvuQ8fJbkr8bs5/ghiIsC7dw9Mt4GXnq+v6XM3+sv9Z7aLRJniFDHJK2x4CvFlE4dsFsJmQCtXtF6NaGB/gAcehathGSXuBjnL2m2205lMPTbHTUEtC/l/hcPKETaA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Aug 07, 2024 at 04:40:21PM GMT, Andrii Nakryiko wrote: > Add freader abstraction that transparently manages fetching and local > mapping of the underlying file page(s) and provides a simple direct data > access interface. > > freader_fetch() is the only and single interface necessary. It accepts > file offset and desired number of bytes that should be accessed, and > will return a kernel mapped pointer that caller can use to dereference > data up to requested size. Requested size can't be bigger than the size > of the extra buffer provided during initialization (because, worst case, > all requested data has to be copied into it, so it's better to flag > wrongly sized buffer unconditionally, regardless if requested data range > is crossing page boundaries or not). > > If folio is not paged in, or some of the conditions are not satisfied, > NULL is returned and more detailed error code can be accessed through > freader->err field. This approach makes the usage of freader_fetch() > cleaner. > > To accommodate accessing file data that crosses folio boundaries, user > has to provide an extra buffer that will be used to make a local copy, > if necessary. This is done to maintain a simple linear pointer data > access interface. > > We switch existing build ID parsing logic to it, without changing or > lifting any of the existing constraints, yet. This will be done > separately. > > Given existing code was written with the assumption that it's always > working with a single (first) page of the underlying ELF file, logic > passes direct pointers around, which doesn't really work well with > freader approach and would be limiting when removing the single page (folio) > limitation. So we adjust all the logic to work in terms of file offsets. > > There is also a memory buffer-based version (freader_init_from_mem()) > for cases when desired data is already available in kernel memory. This > is used for parsing vmlinux's own build ID note. In this mode assumption > is that provided data starts at "file offset" zero, which works great > when parsing ELF notes sections, as all the parsing logic is relative to > note section's start. > > Signed-off-by: Andrii Nakryiko Reviewed-by: Shakeel Butt