linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Andrii Nakryiko <andrii@kernel.org>
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
Date: Thu, 8 Aug 2024 11:33:30 -0700	[thread overview]
Message-ID: <csmgbp57f7o2tbuodolhzb5d2fjdu7l5zwmi7gbvq77bx7s72y@i5kalfb4inwy> (raw)
In-Reply-To: <20240807234029.456316-3-andrii@kernel.org>

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 <andrii@kernel.org>

Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>


       reply	other threads:[~2024-08-08 18:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240807234029.456316-1-andrii@kernel.org>
     [not found] ` <20240807234029.456316-3-andrii@kernel.org>
2024-08-08 18:33   ` Shakeel Butt [this message]
     [not found] ` <20240807234029.456316-7-andrii@kernel.org>
2024-08-08 18:40   ` [PATCH v4 bpf-next 06/10] lib/buildid: implement sleepable build_id_parse() API Shakeel Butt
2024-08-08 20:15     ` Andrii Nakryiko
2024-08-08 20:57       ` Jann Horn
2024-08-08 21:23         ` Andrii Nakryiko
2024-08-08 21:02       ` Shakeel Butt
2024-08-08 21:21         ` Andrii Nakryiko
     [not found] ` <20240807234029.456316-2-andrii@kernel.org>
2024-08-08 22:24   ` [PATCH v4 bpf-next 01/10] lib/buildid: harden build ID parsing logic Andi Kleen
2024-08-08 22:44     ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=csmgbp57f7o2tbuodolhzb5d2fjdu7l5zwmi7gbvq77bx7s72y@i5kalfb4inwy \
    --to=shakeel.butt@linux.dev \
    --cc=adobriyan@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osandov@osandov.com \
    --cc=song@kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox