Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3418121imm; Tue, 29 May 2018 06:59:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrJHpm4XF2duIq3rSm0up9LtKvsTltzqmGQRvG/UC00WdsRyNrONIhvhPEOrx2U3ArzB8sP X-Received: by 2002:a17:902:7406:: with SMTP id g6-v6mr17325433pll.90.1527602396575; Tue, 29 May 2018 06:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527602396; cv=none; d=google.com; s=arc-20160816; b=ZIAMSrwX7fqRFkuC7QmtKpxzYmq8AnqYVdmv4oax9uBIzHnytZwJaIJP1u+mfU6j5w SHYkjnuHXRNSKycuCKjIEMztXkSRRIh60gC9RIHhlRApQB0HdkCNx9oAACMafjzKyLsm Np1NNvAdr0kbng0t0hQe13LamFz2iB+rVJ8e0zlKm+n1FkN39egAa5zDVNC8Y0Q8ABtw 6eQ9vCPWBFbRcPVZNHkfB184oP5vfsyv39+tSxdDY49FcWuboWPfE5ADlXJMs+oTLTnU m6ZfbVbiYN86t9EKUQedjtEtVuGQbqhTcu1rGEB5HDGvyCg+VjIU9EI31n2ff1TprpN0 m3DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=19oo3gG5lG8wN38hSlrbrK52MYBgNHDHWTGnS8d/bhg=; b=hmTA7wD5omLuICaFPYZxdI+zb5wCaViQM373HpvL0q+CYUrm1gNn5M6DMZiLwVKK+4 fi3tOK2MNA8jXUd9Lay+1GbKGt1xVV9aOPoDoep2Xi6tJStuACOVzNhpN61eoU+k/gdE JAX1WHwzyjdeF09F5yx63JFXMtmWifu2DkhVz+vIrzcvQD0GGmeBF4ssOv7D/uNWzOFu dYBzmsQMU9u86phhK+7ZnNlKrEDIiXe4bol2lQpkZ/JMqeL0Li21WibozQdAI0UtfFDE lhd9/AtTZp1GG0xnKYyRUV/kKKNWYLQeFAvwcqI6LfTeCb3M4V5M+qsQBdNFQ1QvM6gv xgFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=AXBRIcFN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si31463656plt.149.2018.05.29.06.59.41; Tue, 29 May 2018 06:59:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=AXBRIcFN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934943AbeE2N7H (ORCPT + 99 others); Tue, 29 May 2018 09:59:07 -0400 Received: from a9-99.smtp-out.amazonses.com ([54.240.9.99]:35350 "EHLO a9-99.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935745AbeE2N6M (ORCPT ); Tue, 29 May 2018 09:58:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1527602291; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=19oo3gG5lG8wN38hSlrbrK52MYBgNHDHWTGnS8d/bhg=; b=AXBRIcFN5TWP7bXiXIKvSuQFo4pZ/mwo3aVgz6jfVx94djmov714y6+/x2KGIamN x9QlEzJ3/HDV9Epip1MLKwsQ0VMPKE+p8ffPHzJPk+hZckZLViBHKfZ+7klaAQnHsTU 9O/1lXL8+/Cfgk5wsGwsV+mCh7xjOCa9VeGZ4LeQ= Date: Tue, 29 May 2018 13:58:11 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Vladimir Davydov cc: Shakeel Butt , Michal Hocko , Andrew Morton , Greg Thelen , Pekka Enberg , David Rientjes , Joonsoo Kim , Johannes Weiner , Tejun Heo , Linux MM , cgroups@vger.kernel.org, LKML Subject: Re: [PATCH v2] mm: fix race between kmem_cache destroy, create and deactivate In-Reply-To: <20180526185837.k5ztrillokpi65qj@esperanza> Message-ID: <01000163ac3122e8-e705287a-17f4-4ff6-8eae-1ad310676096-000000@email.amazonses.com> References: <20180522201336.196994-1-shakeelb@google.com> <20180526185837.k5ztrillokpi65qj@esperanza> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2018.05.29-54.240.9.99 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 26 May 2018, Vladimir Davydov wrote: > > The reference counting is only implemented for root kmem_caches for > > simplicity. The reference of a root kmem_cache is elevated on sharing or > > while its memcg kmem_cache creation or deactivation request is in the > > fly and thus it is made sure that the root kmem_cache is not destroyed > > in the middle. As the reference of kmem_cache is elevated on sharing, > > the 'shared_count' does not need any locking protection as at worst it > > can be out-dated for a small window which is tolerable. > > I wonder if we could fix this problem without introducing reference > counting for kmem caches (which seems a bit of an overkill to me TBO), > e.g. by flushing memcg_kmem_cache_wq before root cache destruction? Would prefer that too but the whole memcg handling is something of a mystery to me.