Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1740223
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: kernFS/sysfs: mmap and vm_operations close |
| Date | 2017-09-26 23:40 +0200 |
| Message-ID | <uu5K9-1HA-17@gated-at.bofh.it> (permalink) |
| References | <uu0r7-6G9-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, Sep 26, 2017 at 05:50:55PM +0200, Federico Vaga wrote: > Hello, > > I'm writing a sysfs binary attribute that makes use of the `mmap` operation. Eeek, why? What are you using that for? sysfs binary attributes are for dumping binary data that the kernel doesn't touch/parse, through to hardware. Why use mmap for this? Do you have a pointer to your code somewhere? > I would like to implement my own `open()` and `close()` `vm_ops` but > apparently I'm not allowed to do it. Nope, you are not, not in sysfs :) > > -------- 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" ? Because you shouldn't be doing that :) > Is there an alternative/hack in order to be notified when the mmap is not used > anymore and I can properly release my resources? Don't use mmap in sysfs :) > 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` Don't use mmap in sysfs :) What problem are you trying to solve here that mmap seemed like the correct solution? thanks, greg k-h
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
kernFS/sysfs: mmap and vm_operations close Federico Vaga <federico.vaga@vaga.pv.it> - 2017-09-26 18:00 +0200
Re: kernFS/sysfs: mmap and vm_operations close Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-26 23:40 +0200
Re: kernFS/sysfs: mmap and vm_operations close Federico Vaga <federico.vaga@vaga.pv.it> - 2017-09-27 08:50 +0200
Re: kernFS/sysfs: mmap and vm_operations close Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-27 09:50 +0200
Re: kernFS/sysfs: mmap and vm_operations close Federico Vaga <federico.vaga@vaga.pv.it> - 2017-09-27 11:40 +0200
csiph-web