public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* kernFS/sysfs: mmap and vm_operations close
@ 2017-09-26 15:50 Federico Vaga
  2017-09-26 21:31 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Federico Vaga @ 2017-09-26 15:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Tejun Heo; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-27  9:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-26 15:50 kernFS/sysfs: mmap and vm_operations close Federico Vaga
2017-09-26 21:31 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox