From: Ralph Campbell <rcampbell@nvidia.com>
To: Christoph Hellwig <hch@lst.de>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Jerome Glisse <jglisse@redhat.com>,
John Hubbard <jhubbard@nvidia.com>,
Jason Gunthorpe <jgg@mellanox.com>, Shuah Khan <shuah@kernel.org>,
<linux-rdma@vger.kernel.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH v4 2/2] mm/hmm/test: add self tests for HMM
Date: Tue, 12 Nov 2019 13:51:11 -0800 [thread overview]
Message-ID: <07589a71-3984-b2a6-b24b-6b9a23e1b60d@nvidia.com> (raw)
In-Reply-To: <20191112152521.GC12550@lst.de>
On 11/12/19 7:25 AM, Christoph Hellwig wrote:
> Shouldn't this go into mm/ instead? It certainly doesn't seem
> like a library.
I was following the convention for the other vm test kernel modules.
I see a couple of modules in mm/ but I don't have a personal
preference for where to place it.
Andrew, do you have a preference?
>> +static int dmirror_bounce_copy_from(struct dmirror_bounce *bounce,
>> + unsigned long addr)
>> +{
>> + unsigned long end = addr + bounce->size;
>> + char __user *uptr = (void __user *)addr;
>> + void *ptr = bounce->ptr;
>> +
>> + for (; addr < end; addr += PAGE_SIZE, ptr += PAGE_SIZE,
>> + uptr += PAGE_SIZE) {
>> + int ret;
>> +
>> + ret = copy_from_user(ptr, uptr, PAGE_SIZE);
>> + if (ret)
>> + return ret;
>> + }
>> +
>> + return 0;
>> +}
>
> Why does this iterate in page sized chunks? I don't remember a page
> size limit on copy_{from,to}_user.
Good point. I'll fix that.
>> +static int dmirror_invalidate_range_start(struct mmu_notifier *mn,
>> + const struct mmu_notifier_range *update)
>> +{
>> + struct dmirror *dmirror = container_of(mn, struct dmirror, notifier);
>> +
>> + if (mmu_notifier_range_blockable(update))
>> + mutex_lock(&dmirror->mutex);
>> + else if (!mutex_trylock(&dmirror->mutex))
>> + return -EAGAIN;
>> +
>> + dmirror_do_update(dmirror, update->start, update->end);
>> + mutex_unlock(&dmirror->mutex);
>> + return 0;
>> +}
>
> Can we adopts this to Jasons new interval tree invalidate?
Well, it would mean registering for the whole process address space.
I'll give it a try.
>> +static int dmirror_fops_open(struct inode *inode, struct file *filp)
>> +{
>> + struct cdev *cdev = inode->i_cdev;
>> + struct dmirror_device *mdevice;
>> + struct dmirror *dmirror;
>> +
>> + /* No exclusive opens. */
>> + if (filp->f_flags & O_EXCL)
>> + return -EINVAL;
>
> Device files usually just ignore O_EXCL, I don't see why this one
> would be any different.
OK, I'll remove that test.
>> + mdevice = container_of(cdev, struct dmirror_device, cdevice);
>> + dmirror = dmirror_new(mdevice);
>> + if (!dmirror)
>> + return -ENOMEM;
>> +
>> + /* Only the first open registers the address space. */
>> + mutex_lock(&mdevice->devmem_lock);
>> + if (filp->private_data)
>> + goto err_busy;
>> + filp->private_data = dmirror;
>> + mutex_unlock(&mdevice->devmem_lock);
>
> ->open is only called for the first open of a given file structure..
>
>> +static int dmirror_fops_release(struct inode *inode, struct file *filp)
>> +{
>> + struct dmirror *dmirror = filp->private_data;
>> +
>> + if (!dmirror)
>> + return 0;
>
> This can't happen if your ->open never returns 0 without setting the
> private data.
>
>> + filp->private_data = NULL;
>
> The file is feed afterwards, no need to clear the private data.
OK, I'll clean that up.
next prev parent reply other threads:[~2019-11-12 21:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-04 22:21 [PATCH v4 0/2] HMM tests and minor fixes Ralph Campbell
2019-11-04 22:21 ` [PATCH v4 1/2] mm/hmm: make full use of walk_page_range() Ralph Campbell
2019-11-12 15:18 ` Christoph Hellwig
2019-11-12 22:21 ` Ralph Campbell
2019-11-14 14:24 ` Jason Gunthorpe
2019-11-04 22:21 ` [PATCH v4 2/2] mm/hmm/test: add self tests for HMM Ralph Campbell
2019-11-12 15:25 ` Christoph Hellwig
2019-11-12 21:51 ` Ralph Campbell [this message]
2019-11-12 23:45 ` Jason Gunthorpe
2019-11-13 13:51 ` Christoph Hellwig
2019-11-14 23:06 ` Ralph Campbell
2019-11-15 14:06 ` Jason Gunthorpe
2019-11-18 18:32 ` Ralph Campbell
2019-11-18 18:42 ` Jason Gunthorpe
2019-11-13 0:08 ` Andrew Morton
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=07589a71-3984-b2a6-b24b-6b9a23e1b60d@nvidia.com \
--to=rcampbell@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=jgg@mellanox.com \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=shuah@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