Skip to content
Snippets Groups Projects
  • Patrick Farrell's avatar
    d5c58329
    LU-8276 ldlm: Make lru clear always discard read lock pages · d5c58329
    Patrick Farrell authored
    A significant amount of time is sometimes spent during
    lru clearing (IE, echo 'clear' > lru_size) checking
    pages to see if they are covered by another read lock.
    Since all unused read locks will be destroyed by this
    operation, the pages will be freed momentarily anyway,
    and this is a waste of time.
    
    This patch sets the LDLM_FL_DISCARD_DATA flag on all the PR
    locks which are slated for cancellation by
    ldlm_prepare_lru_list when it is called from
    ldlm_ns_drop_cache.
    
    The case where another lock covers those pages (and is in
    use and so does not get cancelled by lru clear) is safe for
    a few reasons:
    
    1. When discarding pages, we wait (discard_cb->cl_page_own)
    until they are in the cached state before invalidating.
    So if they are actively in use, we'll wait until that use
    is done.
    
    2. Removal of pages under a read lock is something that can
    happen due to memory pressure, since these are VFS cache
    pages. If a client reads something which is then removed
    from the cache and goes to read it again, this will simply
    generate a new read request.
    
    This has a performance cost for that reader, but if anyone
    is clearing the ldlm lru while actively doing I/O in that
    namespace, then they cannot expect good performance.
    
    In the case of many read locks on a single resource, this
    improves cleanup time dramatically.  In internal testing at
    Cray with ~80,000 read locks on a single file, this improves
    cleanup time from ~60 seconds to ~0.5 seconds.  This also
    slightly improves cleanup speed in the case of 1 or a few
    read locks on a file.
    
    Lustre-change: https://review.whamcloud.com/20785
    
    
    Lustre-commit: 6a369b59
    
    Signed-off-by: default avatarPatrick Farrell <paf@cray.com>
    Change-Id: I0c076b31ea474bb5f012373ed2033de3e447b62d
    Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
    Reviewed-by: default avatarJinshan Xiong <jinshan.xiong@intel.com>
    Signed-off-by: default avatarMinh Diep <minh.diep@intel.com>
    Reviewed-on: https://review.whamcloud.com/29264
    
    
    Tested-by: Jenkins
    Tested-by: default avatarMaloo <hpdd-maloo@intel.com>
    Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
    d5c58329
    History
    LU-8276 ldlm: Make lru clear always discard read lock pages
    Patrick Farrell authored
    A significant amount of time is sometimes spent during
    lru clearing (IE, echo 'clear' > lru_size) checking
    pages to see if they are covered by another read lock.
    Since all unused read locks will be destroyed by this
    operation, the pages will be freed momentarily anyway,
    and this is a waste of time.
    
    This patch sets the LDLM_FL_DISCARD_DATA flag on all the PR
    locks which are slated for cancellation by
    ldlm_prepare_lru_list when it is called from
    ldlm_ns_drop_cache.
    
    The case where another lock covers those pages (and is in
    use and so does not get cancelled by lru clear) is safe for
    a few reasons:
    
    1. When discarding pages, we wait (discard_cb->cl_page_own)
    until they are in the cached state before invalidating.
    So if they are actively in use, we'll wait until that use
    is done.
    
    2. Removal of pages under a read lock is something that can
    happen due to memory pressure, since these are VFS cache
    pages. If a client reads something which is then removed
    from the cache and goes to read it again, this will simply
    generate a new read request.
    
    This has a performance cost for that reader, but if anyone
    is clearing the ldlm lru while actively doing I/O in that
    namespace, then they cannot expect good performance.
    
    In the case of many read locks on a single resource, this
    improves cleanup time dramatically.  In internal testing at
    Cray with ~80,000 read locks on a single file, this improves
    cleanup time from ~60 seconds to ~0.5 seconds.  This also
    slightly improves cleanup speed in the case of 1 or a few
    read locks on a file.
    
    Lustre-change: https://review.whamcloud.com/20785
    
    
    Lustre-commit: 6a369b59
    
    Signed-off-by: default avatarPatrick Farrell <paf@cray.com>
    Change-Id: I0c076b31ea474bb5f012373ed2033de3e447b62d
    Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
    Reviewed-by: default avatarJinshan Xiong <jinshan.xiong@intel.com>
    Signed-off-by: default avatarMinh Diep <minh.diep@intel.com>
    Reviewed-on: https://review.whamcloud.com/29264
    
    
    Tested-by: Jenkins
    Tested-by: default avatarMaloo <hpdd-maloo@intel.com>
    Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>