public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Federico Vaga <federico.vaga@vaga.pv.it>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: kernFS/sysfs: mmap and vm_operations close
Date: Tue, 26 Sep 2017 17:50:55 +0200	[thread overview]
Message-ID: <1630389.Mmh9faUyQX@number-5> (raw)

Hello,

I'm writing a sysfs binary attribute that makes use of the `mmap` operation.
I would like to implement my own `open()` and `close()` `vm_ops` but 
apparently I'm not allowed to do it.

-------- kernfs/file.c - kernfs_fop_mmap () - modern kernel -----
-------- sysfs/bin.c - mmap () - old kernel -----

        /*
         * It is not possible to successfully wrap close.
         * So error if someone is trying to use close.
         */
        rc = -EINVAL;
        if (vma->vm_ops && vma->vm_ops->close)
                goto out_put;
----------------------------------------------------------

What is the reason behind this choice?
Why "it is not possible to successfully wrap close" ?

Is there an alternative/hack in order to be notified when the mmap is not used 
anymore and I can properly release my resources?

Due to HW resources limitation I "cannot" keep the device memory mapped when 
nobody is using it, that's why I would like to be able to use vm_ops->close(). 
In general, I would like to run my routine that release resources when the 
user does `munmap` or `close`


thank you very much :)

-- 
Federico Vaga
http://www.federicovaga.it

             reply	other threads:[~2017-09-26 15:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26 15:50 Federico Vaga [this message]
2017-09-26 21:31 ` kernFS/sysfs: mmap and vm_operations close Greg Kroah-Hartman
2017-09-27  6:41   ` Federico Vaga
2017-09-27  7:45     ` Greg Kroah-Hartman
2017-09-27  9:38       ` Federico Vaga

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=1630389.Mmh9faUyQX@number-5 \
    --to=federico.vaga@vaga.pv.it \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@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