Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932732AbcC3IJ7 (ORCPT ); Wed, 30 Mar 2016 04:09:59 -0400 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:58002 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932622AbcC3IJT (ORCPT ); Wed, 30 Mar 2016 04:09:19 -0400 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: iamjoonsoo.kim@lge.com X-Original-SENDERIP: 10.177.222.138 X-Original-MAILFROM: iamjoonsoo.kim@lge.com Date: Wed, 30 Mar 2016 17:11:16 +0900 From: Joonsoo Kim To: Christoph Lameter Cc: Andrew Morton , Pekka Enberg , David Rientjes , Jesper Dangaard Brouer , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/11] mm/slab: hold a slab_mutex when calling __kmem_cache_shrink() Message-ID: <20160330081116.GA1678@js1304-P5Q-DELUXE> References: <1459142821-20303-1-git-send-email-iamjoonsoo.kim@lge.com> <1459142821-20303-2-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1478 Lines: 30 On Mon, Mar 28, 2016 at 07:50:36PM -0500, Christoph Lameter wrote: > On Mon, 28 Mar 2016, js1304@gmail.com wrote: > > > Major kmem_cache metadata in slab subsystem is synchronized with > > the slab_mutex. In SLAB, if some of them is changed, node's shared > > array cache would be freed and re-populated. If __kmem_cache_shrink() > > is called at the same time, it will call drain_array() with n->shared > > without holding node lock so problem can happen. > > > > We can fix this small theoretical race condition by holding node lock > > in drain_array(), but, holding a slab_mutex in kmem_cache_shrink() > > looks more appropriate solution because stable state would make things > > less error-prone and this is not performance critical path. > > Ummm.. The mutex taking is added to common code. So this will also affect > SLUB. The patch needs to consider this. Do we want to force all > allocators to run shrinking only when holding the lock? SLUB does not > need to hold the mutex. And frankly the mutex is for reconfiguration of > metadata which is *not* occurring here. A shrink operation does not do > that. Can we figure out a slab specific way of handling synchronization > in the strange free/realloc cycle? > > It seems that taking the node lock is the appropriate level of > synchrnonization since the concern is with the contents of a shared cache > at that level. There is no change of metadata which would require the > mutex. Okay. I will fix it. Thanks.