outreachy.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Julia Lawall <julia.lawall@inria.fr>,
	ira.weiny@intel.com,
	 Alaa Mohamed <eng.alaamohamedsoliman.am@gmail.com>,
	 outreachy@lists.linux.dev, boris.ostrovsky@oracle.com,
	jgross@suse.com,  sstabellini@kernel.org,
	xen-devel@lists.xenproject.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] xen:  Convert kmap() to kmap_local_page()
Date: Wed, 20 Apr 2022 15:40:10 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2204201538560.2937@hadrien> (raw)
In-Reply-To: <2940450.687JKscXgg@leap>

[-- Attachment #1: Type: text/plain, Size: 1803 bytes --]



On Wed, 20 Apr 2022, Fabio M. De Francesco wrote:

> On mercoledì 20 aprile 2022 08:03:05 CEST Julia Lawall wrote:
> >
> > On Wed, 20 Apr 2022, Alaa Mohamed wrote:
> >
> > > kmap() is being deprecated and these usages are all local to the thread
> > > so there is no reason kmap_local_page() can't be used.
> > >
> > > Replace kmap() calls with kmap_local_page().
> >
> > OK, so from a Coccinelle point of view, could we do
> >
> > @@
> > expression e1,e2,x,f;
> > @@
> >
> > e1 =
> > - kmap
> > + kmap_local_page
> >     (e2)
> > ... when != x = e1 // not stored in any location and not passed to
> another function
> >     when != f(...,e1,...)
> >     when != x = e2
> >     when != f(...,e2,...)
> > -kunmap(e2)
> > +kunmap_local(e1)
> >
> > julia
> >
>
> I've never spent sufficient time to understand properly the syntax and
> semantics of expressions of Coccinelle. However, thanks Julia, this code
> looks good and can be very helpful.
>
> Only a minor objection... it doesn't tell when 'e2' has been allocated
> within the same function where the kmap() call is.
>
> In the particular case that I cite above, I'd prefer to remove the
> allocation of the page (say with alloc_page()) and convert kmap() /kunmap()
> to use kmalloc() / kfree().
>
> Fox example, this is done in the following patch:
>
> commit 633b0616cfe0 ("x86/sgx: Remove unnecessary kmap() from
> sgx_ioc_enclave_init()") from Ira Weiny.
>
> Can Coccinelle catch also those special cases where a page that is passed
> to kmap() is allocated within that same function (vs. being passed as
> argument to this function) and, if so, propose a replacement with
> kmalloc()?

It looks complex in this case, because the allocation is in another
function, and it is passed to another function.

julia


>
> Thanks,
>
> Fabio
>
>
>
>

  parent reply	other threads:[~2022-04-20 13:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-19 23:43 [PATCH v2] xen: Convert kmap() to kmap_local_page() Alaa Mohamed
2022-04-20  6:03 ` Julia Lawall
2022-04-20 13:22   ` Fabio M. De Francesco
2022-04-20 13:28     ` Julia Lawall
2022-04-20 13:40     ` Julia Lawall [this message]
2022-04-20 13:55       ` Fabio M. De Francesco
2022-04-20 13:57         ` Julia Lawall
2022-04-20 14:07           ` Fabio M. De Francesco
2022-04-25 15:29             ` Ira Weiny
2022-04-25 15:34               ` Julia Lawall
2022-04-21 21:15 ` Boris Ostrovsky

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=alpine.DEB.2.22.394.2204201538560.2937@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=boris.ostrovsky@oracle.com \
    --cc=eng.alaamohamedsoliman.am@gmail.com \
    --cc=fmdefrancesco@gmail.com \
    --cc=ira.weiny@intel.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=outreachy@lists.linux.dev \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).