mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "stephane eranian" <eranian@googlemail.com>
To: "Thomas Gleixner" <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	mingo@elte.hu, x86@kernel.org, andi@firstfloor.org,
	sfr@canb.auug.org.au
Subject: Re: [patch 20/24] perfmon: system calls interface
Date: Mon, 1 Dec 2008 07:10:36 +0100	[thread overview]
Message-ID: <7c86c4470811302210p5fb1f0c8re7d74945eb3e0253@mail.gmail.com> (raw)
In-Reply-To: <alpine.LFD.2.00.0811271454120.3325@localhost.localdomain>

Thomas,

On Thu, Nov 27, 2008 at 3:01 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Wed, 26 Nov 2008, eranian@googlemail.com wrote:
>
>> +asmlinkage long sys_pfm_write(int fd, int uflags,
>> +                           int type,
>> +                           void __user *ureq,
>> +                           size_t sz)
>
>> +asmlinkage long sys_pfm_read(int fd, int uflags,
>> +                          int type,
>> +                          void __user *ureq,
>> +                          size_t sz)
>
> After looking at both I did a diff of the two functions:
>
> --- r.c 2008-11-27 14:27:54.000000000 +0100
> +++ w.c 2008-11-27 14:27:52.000000000 +0100
> @@ -36,10 +36,12 @@
>        ret = pfm_check_task_state(ctx, PFM_CMD_STOPPED, &flags);
>        if (ret)
>                goto skip;
> -
>        switch(type) {
> +       case PFM_RW_PMC:
> +               ret = __pfm_write_pmcs(ctx, req, count);
> +               break;
>        case PFM_RW_PMD:
> -               ret = __pfm_read_pmds(ctx, req, count);
> +               ret = __pfm_write_pmds(ctx, req, count);
>                break;
>        default:
>                PFM_DBG("invalid type=%d", type);
> @@ -48,12 +50,13 @@
>  skip:
>        spin_unlock_irqrestore(&ctx->lock, flags);
>
> -       if (copy_to_user(ureq, req, sz))
> -               ret = -EFAULT;
> -
> +       /*
> +        * This function may be on the critical path.
> +        * We want to avoid the branch if unecessary.
> +        */
>        if (fptr)
>                kfree(fptr);
>  error:
>        pfm_release_ctx_from_fd(&cookie);
>        return ret;
>  }
>
> Both read and write are multiplexing syscalls already and 90% of the
> code is the same.
>
>        case PFM_RD_PMC:
>        case PFM_RD_PMD:
>        case PFM_WR_PMC:
>        case PFM_WR_PMD:
>
> would make them the same and safe a syscall and duplicated code.
>
I have some issues with this approach because in the API I have tried to follow
the model where the  syscall name describes the action taken (only one
per call):
    - create
    - read
    - write
    - set_state
    - attach/detach I admit this one is not so clean. But Ingo
indicated he would prefer them as separate which I am
      happy to do (it was like this originally)

  parent reply	other threads:[~2008-12-01  6:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-26  8:42 eranian
2008-11-26 12:02 ` Andi Kleen
2008-11-26 13:43 ` Ingo Molnar
2008-11-26 14:00 ` Ingo Molnar
2008-11-26 16:59   ` Oleg Nesterov
2008-11-27 12:25     ` stephane eranian
2008-11-27 12:41       ` Andi Kleen
2008-11-27 14:22   ` stephane eranian
2008-11-27 14:42     ` Ingo Molnar
2008-11-27 15:16       ` stephane eranian
2008-12-01  0:49     ` Paul Mackerras
2008-12-01  6:05       ` stephane eranian
2008-12-03  2:02   ` Roland McGrath
2008-12-04  1:05   ` Roland McGrath
2008-11-26 14:02 ` Ingo Molnar
2008-11-26 14:08 ` Ingo Molnar
2008-11-27 14:28   ` stephane eranian
2008-11-26 14:11 ` Ingo Molnar
2008-11-26 14:13 ` Ingo Molnar
2008-11-27 14:01 ` Thomas Gleixner
2008-11-27 14:07   ` stephane eranian
2008-12-01  6:10   ` stephane eranian [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-11-25 21:36 eranian

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=7c86c4470811302210p5fb1f0c8re7d74945eb3e0253@mail.gmail.com \
    --to=eranian@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=eranian@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sfr@canb.auug.org.au \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®