Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5054959imm; Tue, 12 Jun 2018 01:35:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKIhX6PDYPESzE16M9NtujdBcOwa+b5gjaXuPGiviO8FNBs4g+jAx3PnIVmh8mpuyupMnca X-Received: by 2002:a17:902:4101:: with SMTP id e1-v6mr3004647pld.205.1528792520291; Tue, 12 Jun 2018 01:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528792520; cv=none; d=google.com; s=arc-20160816; b=uALNMjiyxrFYKWiFDqub5IEXAWarIkQHG6ZwUTYWhPG/jTbhDM5X1Vd+Yoq2fgQcIh 93IuuFZEksUlpj8INmkOZKPWrhrRVCZHBedqq+mNJf8C/ppQV7GRzefDZRYxy3wKwfjq +Y3KIWpwuCssUuznB9m/QDg8FzzLZ7SmJFQrXP3GZPHGefTXHjvK3GLrSMmPX2AuGpyD 35i4eHBiFPLUfqkb/9pCY71waaineRbEfD9RxK7AagoFupfA8pz2/baOpkhUAaPQ4nr/ 4ZUQFkJKHe5wsgbbEF5CZjj/3IGWOC7KfY414Vk+qkqvSBseYNs/tdxAWFso6ndzonqm pWkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=2CUoKXg/Jtc5sIdU2xR4mhcen0nTu7a2lUGvIEAuSVw=; b=x6NysDhmmkox3hZ2ZjGZgfFcHA5dRsv+HiQcYPv7/d7GWbHIMGldhF6cLdcg0O/c23 iZBv15XZNjzBFOIjOr6FkVjNvB4zppOyBD0jsCpScpssElTurBFlhxVcQ21fnw9W5NKM upnoqkBvXjRYUdO4CeQlG/dXVfgo665RpyPUOzyY1VvMinTEBqmpeBRF9nEoyDJdQeL0 rMIomsgAvEt9ORc9anfVu+ouYpIO/rMwnXqDYbI5pU6m7hJPk3UoordQKwPeGq4UF5EC AT1T0N6Xlji44/CeOI+dZ+a6zkJgfZMFYNHv3td9XoduIuwzvpwOaC3Un42IlsiqVkhm IBgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EOuJGpy8; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v73-v6si376019pfi.22.2018.06.12.01.35.05; Tue, 12 Jun 2018 01:35:20 -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=@gmail.com header.s=20161025 header.b=EOuJGpy8; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754317AbeFLIdV (ORCPT + 99 others); Tue, 12 Jun 2018 04:33:21 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:38336 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754288AbeFLIdT (ORCPT ); Tue, 12 Jun 2018 04:33:19 -0400 Received: by mail-lf0-f65.google.com with SMTP id i83-v6so34678960lfh.5; Tue, 12 Jun 2018 01:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2CUoKXg/Jtc5sIdU2xR4mhcen0nTu7a2lUGvIEAuSVw=; b=EOuJGpy8lYROQorMGNi92tF5uE0GVcl+EICrGulTwEvZFQoZQDG5b7q4aNubDCN7Gq J3cHkLo+4OnA8cxGvy3I+d/6J2dHliSmpid1NYfMqnv/fmjLnCxNl4cMIjzhfxfb2WS9 qz9nNDbWPaRtmtittPfWdJO0915lN0q+Fek5/Z2HzsgfNtQ2DqpfgfI6wpv2GC6oCR7g JCR7/gZy13y+qYEjgK0gArY9MwZjk+bDhxtdM12cA7kxtWdyqScwg4IKhEDN5PO+jTzl wuU6EI/tA0dpAhtG4a03h9bK0bFYV9+OLKFH0eZzVZQqSVyfH5Bl+jatkpHq6erNgQNI OOoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2CUoKXg/Jtc5sIdU2xR4mhcen0nTu7a2lUGvIEAuSVw=; b=qVXxJQpS58z37HUmmZrxUlCg6YVxG+nAKS4q2bXtJcrNJZUOWFi3UQZMatku9D8gLT BlDoOmk+UXctkFA88TKkRSs3xAQ66Ktu1XfzqdxaQhPm15iNiWhpkWjCFizHmyavBajZ cW/25VL3F8Iy+E5tjtXJZDpTzvhi9w+lJEUyIZROhzXCBkq/DeGNjb4FEjB+YL1AsiO7 y8jYgNnER1qV2xYdJUG0Td+atOKemJ/nttWEXPeAoiEoulHLAxpVs1YPNNRJ4c4Bjqw8 XVBWgU3/fLsDNpBcrvvn0Qqul4Q+yEgQDIpqjKd8owI7+5klf5jkrn0kO7QBj5tBkYJG zh3g== X-Gm-Message-State: APt69E3JxSoF/ja9u9fEbiOJ0xNDcddZ9sPAHzH0mRJbFZarWieIR4v+ 7uZa7SicYpMMrqK4RDW2l+o= X-Received: by 2002:a2e:529c:: with SMTP id n28-v6mr1779627lje.62.1528792397884; Tue, 12 Jun 2018 01:33:17 -0700 (PDT) Received: from esperanza (81.5.110.211.dhcp.mipt-telecom.ru. [81.5.110.211]) by smtp.gmail.com with ESMTPSA id r64-v6sm79341lff.90.2018.06.12.01.33.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jun 2018 01:33:16 -0700 (PDT) Date: Tue, 12 Jun 2018 11:33:14 +0300 From: Vladimir Davydov To: Shakeel Butt Cc: Michal Hocko , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Greg Thelen , Johannes Weiner , Tejun Heo , Linux MM , Cgroups , LKML Subject: Re: [PATCH v4] mm: fix race between kmem_cache destroy, create and deactivate Message-ID: <20180612083314.ftl4hmn4xwnehjdx@esperanza> References: <20180611192951.195727-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180611192951.195727-1-shakeelb@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 11, 2018 at 12:29:51PM -0700, Shakeel Butt wrote: > The memcg kmem cache creation and deactivation (SLUB only) is > asynchronous. If a root kmem cache is destroyed whose memcg cache is in > the process of creation or deactivation, the kernel may crash. > > Example of one such crash: > general protection fault: 0000 [#1] SMP PTI > CPU: 1 PID: 1721 Comm: kworker/14:1 Not tainted 4.17.0-smp > ... > Workqueue: memcg_kmem_cache kmemcg_deactivate_workfn > RIP: 0010:has_cpu_slab > ... > Call Trace: > ? on_each_cpu_cond > __kmem_cache_shrink > kmemcg_cache_deact_after_rcu > kmemcg_deactivate_workfn > process_one_work > worker_thread > kthread > ret_from_fork+0x35/0x40 > > To fix this race, on root kmem cache destruction, mark the cache as > dying and flush the workqueue used for memcg kmem cache creation and > deactivation. SLUB's memcg kmem cache deactivation also includes RCU > callback and thus make sure all previous registered RCU callbacks > have completed as well. > > Signed-off-by: Shakeel Butt Acked-by: Vladimir Davydov Thanks.