Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp30765imm; Thu, 31 May 2018 17:49:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLoGRK840yJvC8O9E4TIEaOXjKWxE9KGNOpGOM8nBakl+upaTkUrP+6Vr3NjP/NAbVYe55C X-Received: by 2002:a63:ba56:: with SMTP id l22-v6mr7208543pgu.161.1527814176346; Thu, 31 May 2018 17:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527814176; cv=none; d=google.com; s=arc-20160816; b=z6G2LeK5fPFEy42AoQTadPFmMC157KmDmWTx6qVud0VAkOCf99BH4HoUhFtE+6XpWJ xZJcMpfI0ya+EI0R/fmTr/FP6u/qr7Z8jKuEo60l5Uh4CwglAx4WsznVsOD8wkwj/gz5 HZlYPIs76hZ45npSbOq4R6FUgcfGc7ycyRzMaW4JgY2qtAg2/yXl15nQctfw2ojuaIK5 06C25XUDotoxyeMrdoJilXZH9LbK/JQZiMEpYGCccv4lv9T2kk4pW1bNtYR49OkiDOoX ZlZ0SuAhmF1d4CH9UAbICigUFahPSzAicj8mgxzIHLzz0xfbT9r8VX/u4L4pOHRNVvCN 8gWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=clRbq+UF0DlIBgPmj4jPJVfMDVl21+9YWWUWZkDdQRg=; b=P3fQ4dWf4C2tTTIknnWUi+VHi0WetR9a9NvXRzrcj4NMFdiKGqRe2G5HACeibEqZ72 1qkBxgy01/fWyEccY8P2m7JikxiZWk4SSGyor+Gk9FvbB0BeX9UKTEdZ3IVU1rjsHFKv mI8mff2Oj4CoUOzrC8Wt2mVYvcjaolmlrH6zg8BWLa6QmtVu8OjzgytU+p+ytY9Hi2jK tmmHpgi6Z01QfSKuqNfwtMD7LJYK6/c0qyPDeXAWCtt5PRjtJw4CKOnYvX6721qov+5N hafED3+BR9GrE1/nxVL8OGVWKtFvQDmgA3VtoNb9iKBT7buVSmDwGL6Gg+qGE8KQhpcc GNSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gno8Sjn1; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21-v6si38442358plo.51.2018.05.31.17.49.22; Thu, 31 May 2018 17:49:36 -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=@google.com header.s=20161025 header.b=gno8Sjn1; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751512AbeFAAsi (ORCPT + 99 others); Thu, 31 May 2018 20:48:38 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34383 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbeFAAsd (ORCPT ); Thu, 31 May 2018 20:48:33 -0400 Received: by mail-wr0-f196.google.com with SMTP id j1-v6so34668005wrm.1 for ; Thu, 31 May 2018 17:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=clRbq+UF0DlIBgPmj4jPJVfMDVl21+9YWWUWZkDdQRg=; b=gno8Sjn1gVqotNoi3N+jgHI0NGG3/Dg3QFeDlU5olpEhnxbB2VL5X9uMUEO5TlNdw0 bno/XJxZcy65lvT+1Anurwz2yYZSRVi20WskB0Lx527n+APPJOvQQFReCaElBMpzuUJj PXsNgZDNYmI5iWoRugaIbHe4P8mfwI3Xf9rG06DQLT1B4z7D6H8pFqgsa0SgHQPhQbQX NuxsKC6qxIERRY2BYVyg5/uIqdKhH7/jYDgftYkSUfZA3BTTs+Uh+jVT/whGOwdpaBvl MjhKU22GUWlHdMZYbm2JTMfv8w3XFC7iGGrdxp3C+Su4geM1qei+XEI+4RyhUzZFNhWP UOUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=clRbq+UF0DlIBgPmj4jPJVfMDVl21+9YWWUWZkDdQRg=; b=mvmjvhzuEmYA0Jx5DquC8HlLR6b3WMX0wpfcTfIlCHCzrRNvikIk8Vk946aPjiQPTC kZ/QfbOF/hVsYEUi5F9Kj5juYkvFFJ9vMn+OWH2M04UuFztjCySSjMYSU7oZa16yptLS SipKBcolrSqgXPVTVC/OuLzLJj0TWHxs/Bor0EENaY5Owt+9rpIqOWIhU4wXLzJV4MYU DLRNHLAK25WAPrRd2iEhYlGYfGfNEqrq73q4hDKk/5z5cMGHGKOZnjmcMtH0hG1ZPSU4 LALxbz17ViN2KXKMb/axMNAob5vjua4SLL83eLpVBsmuUrBlHpm8qes6fnL8Ip9NyHzO /ORQ== X-Gm-Message-State: ALKqPwea9C6uG9UJSn0m4BL6I+/C9UgBFdUjCu1S4nhU0o0Tq0B2UV5t bmhkEcIyYmZZ2WULItS+AcWaHM0TK2QlW+UMRg4MAQ== X-Received: by 2002:adf:c98c:: with SMTP id f12-v6mr7151674wrh.272.1527814112495; Thu, 31 May 2018 17:48:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:1286:0:0:0:0:0 with HTTP; Thu, 31 May 2018 17:48:31 -0700 (PDT) In-Reply-To: <20180531171834.e16fc59550d24437a12c612b@linux-foundation.org> References: <20180530001204.183758-1-shakeelb@google.com> <20180531171834.e16fc59550d24437a12c612b@linux-foundation.org> From: Shakeel Butt Date: Thu, 31 May 2018 17:48:31 -0700 Message-ID: Subject: Re: [PATCH v3] mm: fix race between kmem_cache destroy, create and deactivate To: Andrew Morton Cc: Michal Hocko , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Greg Thelen , Johannes Weiner , Vladimir Davydov , Tejun Heo , Linux MM , Cgroups , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 31, 2018 at 5:18 PM, Andrew Morton wrote: > On Tue, 29 May 2018 17:12:04 -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. >> >> Signed-off-by: Shakeel Butt >> --- >> Changelog since v2: >> - Instead of refcount, flush the workqueue > > This one-liner doesn't appear to fully describe the difference between > v2 and v3, which is rather large: > Sorry about that, I should have explained more. The reason the diff between v2 and v3 is large is because v3 is the complete rewrite. So, the diff is the revert of v2 and then v3 patch. If you drop all the previous versions and just keep v3, it will be smaller. thanks, Shakeel