All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: Amitoj Kaur Chawla <amitoj1606@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Coccinelle <cocci@systeme.lip6.fr>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	Michal Marek <mmarek@suse.com>,
	Nicolas Palix <nicolas.palix@imag.fr>
Subject: Re: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions
Date: Mon, 1 Aug 2016 14:03:25 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1608011359210.3188@hadrien> (raw)
In-Reply-To: <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net>



On Mon, 1 Aug 2016, SF Markus Elfring wrote:

> >> 1. Would it make sense to merge such SmPL rules into one
> >>    so that code duplication could be reduced a bit
> >>    in such a script?
> >
> > I think it would suffer in readability.
>
> How do you think about the following SmPL script example?
>
> @vz_combined
>  depends on patch && !context && !org && !report@
> type T;
> T* pointer;
> +statement S;
> expression express;
> @@
>  pointer =
> -          vmalloc
> +          vzalloc
>            (...);
>  if (!d)
>     S
> -memset(d, 0, sizeof(
> (
> -T
> |
> -*(express)
> )
> -));

OK, I thought you meant to make a big disjunctions for all of the before
and after functions.  This is a little better because it is bounded in
size.  But I don't understand why you have introduced the variable
express.  Normally one wants the cleared space to be the allocated size,
which is normally the size of *pointer.

The performance issue is that disjunctions on expressions, eg (A | B), are
implemented as (A | (!A & B)), ie with a negation of all the previous
options &d with each option.  So it is better to avoid very large
disjunctions on expressions.

julia


>
>
> > Perhaps in performance as well.
>
> I admit that I am unsure about the run-time characteristics
> for my suggestion.
>
> Regards,
> Markus
>

WARNING: multiple messages have this Message-ID (diff)
From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions
Date: Mon, 1 Aug 2016 14:03:25 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1608011359210.3188@hadrien> (raw)
In-Reply-To: <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net>



On Mon, 1 Aug 2016, SF Markus Elfring wrote:

> >> 1. Would it make sense to merge such SmPL rules into one
> >>    so that code duplication could be reduced a bit
> >>    in such a script?
> >
> > I think it would suffer in readability.
>
> How do you think about the following SmPL script example?
>
> @vz_combined
>  depends on patch && !context && !org && !report@
> type T;
> T* pointer;
> +statement S;
> expression express;
> @@
>  pointer =
> -          vmalloc
> +          vzalloc
>            (...);
>  if (!d)
>     S
> -memset(d, 0, sizeof(
> (
> -T
> |
> -*(express)
> )
> -));

OK, I thought you meant to make a big disjunctions for all of the before
and after functions.  This is a little better because it is bounded in
size.  But I don't understand why you have introduced the variable
express.  Normally one wants the cleared space to be the allocated size,
which is normally the size of *pointer.

The performance issue is that disjunctions on expressions, eg (A | B), are
implemented as (A | (!A & B)), ie with a negation of all the previous
options &d with each option.  So it is better to avoid very large
disjunctions on expressions.

julia


>
>
> > Perhaps in performance as well.
>
> I admit that I am unsure about the run-time characteristics
> for my suggestion.
>
> Regards,
> Markus
>

  reply	other threads:[~2016-08-01 12:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-01  7:02 [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions Amitoj Kaur Chawla
2016-08-01  7:02 ` [Cocci] " Amitoj Kaur Chawla
2016-08-01 11:23 ` SF Markus Elfring
2016-08-01 11:23   ` SF Markus Elfring
2016-08-01 11:37   ` Julia Lawall
2016-08-01 11:37     ` Julia Lawall
2016-08-01 11:56     ` SF Markus Elfring
2016-08-01 11:56       ` SF Markus Elfring
2016-08-01 12:03       ` Julia Lawall [this message]
2016-08-01 12:03         ` Julia Lawall
2016-08-01 12:24         ` SF Markus Elfring
2016-08-01 12:24           ` SF Markus Elfring
2016-08-01 12:32           ` Julia Lawall
2016-08-01 12:32             ` Julia Lawall
2016-08-01 12:45             ` SF Markus Elfring
2016-08-01 12:45               ` SF Markus Elfring
2016-08-19 12:14   ` Amitoj Kaur Chawla
2016-08-19 12:14     ` Amitoj Kaur Chawla
2016-08-19 12:41     ` Julia Lawall
2016-08-19 12:41       ` Julia Lawall
2016-08-19 13:26     ` [Cocci] " SF Markus Elfring
2016-08-19 13:26       ` SF Markus Elfring
2016-08-19 13:30       ` Julia Lawall
2016-08-19 13:30         ` Julia Lawall
2016-08-19 16:56         ` SF Markus Elfring
2016-08-19 16:56           ` SF Markus Elfring
2017-03-03 10:34 ` [Cocci] [PATCH v3] " SF Markus Elfring
2017-03-03 10:34   ` SF Markus Elfring

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.10.1608011359210.3188@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=Gilles.Muller@lip6.fr \
    --cc=amitoj1606@gmail.com \
    --cc=cocci@systeme.lip6.fr \
    --cc=elfring@users.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.com \
    --cc=nicolas.palix@imag.fr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.