Re: [PATCH v5 12/18] zsmalloc: make zspage lock preemptible

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

 



> 
> > 
> > +{
> > 
> >  + atomic_t *lock = &zspage->lock;
> > 
> >  + int old = ZS_PAGE_UNLOCKED;
> > 
> >  +
> > 
> >  + WARN_ON_ONCE(preemptible());
> > 
> >  
> > 
> >  Hmm I know I may have been the one suggesting this, but do we actually
> > 
> >  need it? We disable preemption explicitly anyway before holding the
> > 
> >  lock.
> > 
> 
> This is just to make sure that the precondition for
> 
> "writer is always atomic" is satisfied. But I can drop it.

Right, but why do we care? Even if the context is not atomic, we disable preemtion and make sure the context stays atomic throughout the lock critical section.

> 
> > 
> > size_class_lock(class);
> > 
> >  - /* the migrate_write_lock protects zpage access via zs_map_object */
> > 
> >  - migrate_write_lock(zspage);
> > 
> >  + /* the zspage write_lock protects zpage access via zs_map_object */
> > 
> >  + if (!zspage_try_write_lock(zspage)) {
> > 
> >  + size_class_unlock(class);
> > 
> >  + pool_write_unlock(pool);
> > 
> >  + return -EINVAL;
> > 
> >  + }
> > 
> >  +
> > 
> >  + /* We're committed, tell the world that this is a Zsmalloc page. */
> > 
> >  + __zpdesc_set_zsmalloc(newzpdesc);
> > 
> >  
> > 
> >  We used to do this earlier on, before any locks are held. Why is it
> > 
> >  moved here?
> > 
> 
> I want to do that only if zspaage write-trylock has succeeded (we didn't
> 
> have any error out paths before).

Ack.





[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