mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: eranian@googlemail.com
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	x86@kernel.org, andi@firstfloor.org, eranian@gmail.com,
	sfr@canb.auug.org.au
Subject: Re: [patch 15/24] perfmon: context creation
Date: Wed, 26 Nov 2008 14:33:53 +0100	[thread overview]
Message-ID: <20081126133353.GA6562@elte.hu> (raw)
In-Reply-To: <492d0bfd.0af6660a.37d8.4b8b@mx.google.com>


* eranian@googlemail.com <eranian@googlemail.com> wrote:

> +/**
> + * pfm_undo_create -- undo context creation
> + * @fd: file descriptor to close
> + * @ctx: newly created context
> + *
> + * upon return neither fd nor ctx are useable
> + */
> +void pfm_undo_create(int fd, struct pfm_context *ctx)
> +{
> +       struct files_struct *files = current->files;
> +       struct file *file;
> +       int fput_needed;
> +
> +       file = fget_light(fd, &fput_needed);
> +       /*
> +	* there is no fd_uninstall(), so we do it
> +	* here. put_unused_fd() does not remove the
> +	* effect of fd_install().
> +	*/
> +
> +       spin_lock(&files->file_lock);
> +       files->fd_array[fd] = NULL;
> +       spin_unlock(&files->file_lock);
> +
> +       fput_light(file, fput_needed);
> +
> +       /*
> +	* decrement ref count and kill file
> +	*/
> +       put_filp(file);
> +
> +       put_unused_fd(fd);
> +
> +       pfm_free_context(ctx);
> +}

This function is superfluous.

The only place where this is used is when a fresh sys_pfm_create() 
fails to do a user-copy of the sif:

+       if (ureq && copy_to_user(ureq, &sif, sizeof(sif))) {
+               pfm_undo_create(ret, new_ctx);
+               ret  = -EFAULT;
+       }

but this code should be calling sys_close(fd) instead - the fd is 
already set up with pfm_fs so it will tear down the context if this 
was the last user of the perfmon context.

So basically pfm_undo_create() is an open-coded sys_close(fd).

	Ingo

  reply	other threads:[~2008-11-26 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-26  8:42 eranian
2008-11-26 13:33 ` Ingo Molnar [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=20081126133353.GA6562@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=eranian@gmail.com \
    --cc=eranian@googlemail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --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®