RE: [PATCH v5 5/9] mm: Introduce mf_dax_kill_procs() for fsdax case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Matthew Wilcox <willy@xxxxxxxxxxxxx>
> Subject: Re: [PATCH v5 5/9] mm: Introduce mf_dax_kill_procs() for fsdax case
> 
> On Mon, Jun 28, 2021 at 08:02:14AM +0800, Shiyang Ruan wrote:
> > +/*
> > + * dax_load_pfn - Load pfn of the DAX entry corresponding to a page
> > + * @mapping:	The file whose entry we want to load
> > + * @index:	offset where the DAX entry located in
> > + *
> > + * Return:	pfn number of the DAX entry
> > + */
> 
> This is an externally visible function; why not add the second '*' and make this
> kernel-doc?

I'll fix this and add kernel-doc.

> 
> > +unsigned long dax_load_pfn(struct address_space *mapping, unsigned
> > +long index) {
> > +	XA_STATE(xas, &mapping->i_pages, index);
> > +	void *entry;
> > +	unsigned long pfn;
> > +
> > +	xas_lock_irq(&xas);
> > +	entry = xas_load(&xas);
> > +	pfn = dax_to_pfn(entry);
> > +	xas_unlock_irq(&xas);
> 
> Why do you need the i_pages lock to do this?  is the rcu_read_lock() insufficient?

I was misusing these locks, not very filmier with them...

So, I think I should learn from dax_lock_page(): rcu_read_lock(), xas_load(&xas, index), and then wait_entry_unlocked(), finally get an unlocked entry, translate to PFN and return.

> For that matter, why use the xas functions?  Why not
> simply:
> 
> 	void *entry = xa_load(&mapping->i_pages, index);
> 	return dax_to_pfn(entry);
> 
> Looking at it more though, how do you know this is a PFN entry?
> It could be locked, for example.  Or the zero page, or empty.

Yes, I didn't take these in consideration.  If this file hasn't been mmapped and accessed, I can't get its PFN rightly.

> 
> But I think this is unnecessary; why not just pass the PFN into mf_dax_kill_procs?

Because the mf_dax_kill_procs() is called in filesystem recovery function, which is at the end of the RMAP routine.  And the PFN has been translated to disk offset in pmem driver in order to do RMAP search in filesystem.  So, if we have to pass it, every function in this routine needs to add an argument for this PFN.  I was hoping I can avoid passing PFN through the whole stack with the help of this dax_load_pfn().

So, based on the above, if a file hasn't been mmapped and accessed, we can't get the right PFN number, which also means no process is associated with this PFN.  Then we don't have to kill any process any more.  Just return with an error code.  mf_dax_kill_porcess() can also return immediately.  How do you think?


--
Thanks,
Ruan.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux