Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3946225imu; Mon, 28 Jan 2019 13:54:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IaBVa8akUQFixguq9aY6cbvrq7z8gYPZHIJ/s+9G2HzSZZxadO84Htut8EeFjFek3VdCwKD X-Received: by 2002:a62:5007:: with SMTP id e7mr11224352pfb.92.1548712494754; Mon, 28 Jan 2019 13:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548712494; cv=none; d=google.com; s=arc-20160816; b=zcY9knfi+INExzBR7nVuzlDdBBLAnc7U5+AFibyedlb3yyA7gXqXFScDCbL8nH386S cpCOD4BKgzvw0TMW0Q1/J+c7y1uN63P584vnUPvGC7me/t3AS8hWls0YBFK1EnvXAGwK hAJRtGFq2kfKSZQpzCB30ih5tQKWZ5diAIO8vg750hOKzmyWUOTLeWfrUf5wLGN5EkKE yGsLLEGdDbVrt6HRLfvexGkclnuYHFbAyIQIkw7MJs3FFnvP56wTnNV+0XhOG0CW+ZoB nhiuPgwJRZTPKFqwD/FVx49o5W7qP2xdknMf6Zl09fwXs+SVV/GxCd5lBXfZz9PYDTL8 Ukdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6fUmvSDmEjz08XKF0ToKqbVBrxXVRyHjyqapg2MBg6Q=; b=wDsBF+RGLvSgwIfxkMH7itjjpM1IaIwBOQCdoMQ2/+5YlQAv7voiTeRf+747Vj/bk9 jy2DvK/lpDezzjYnFb1uapo4sDCaAwLGe8tJuHccefQUDWMqSkybP3AbQqaiu8SAdBP7 OhuV5EBAwTLvTjlvCNTvfMBAESdhpWXCUXxGKnIhh0R9g1w0lMBOIcd8wo9iSb3J/XzY 9oRhABPHY8jQPomIaUIgHjzYrHg1N6XXK8PvHpdBBogVbsQ77StL40FLyLoOVV0O5Qjv IvplMppc6rSEN6eDdClrUKQ/khzu0C4Yf/D7O9ja13E0yaiu2jYK6E5GCYvJXQIT5fUR W07g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=vc03nv96; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d32si31669676pla.136.2019.01.28.13.54.39; Mon, 28 Jan 2019 13:54:54 -0800 (PST) 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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=vc03nv96; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728256AbfA1VxT (ORCPT + 99 others); Mon, 28 Jan 2019 16:53:19 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:43704 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbfA1VxR (ORCPT ); Mon, 28 Jan 2019 16:53:17 -0500 Received: by mail-yw1-f68.google.com with SMTP id n21so7378912ywd.10 for ; Mon, 28 Jan 2019 13:53:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6fUmvSDmEjz08XKF0ToKqbVBrxXVRyHjyqapg2MBg6Q=; b=vc03nv96i0HISo7x2YIJjRidr5L5AP2IUQx6QxFgZmkIVUMJsMRy0c7TK3FrcHSURc aDa2L0TK5Pw30lt66CwIUbIRFXTIeZOeR5wYH0y3ZSoefARez89tTF1w08/hIiX/5Rlh GJjqcQ7j7h3kqaYtO+gCx58GfCaJU3ZPM0wKth+exXBNTulSBbeSLUaDHI0Ec3OnAg4g dByNON9C53Fc1E24EfHoaYt9+4l+UintuPdprpmzY+UswWd8CDo6bAtldH5kxOeofiZ1 YBz7LQltzMI/JmZH1RSxBWnMzbc62P4Qaj5+NnVugVBXwh5S9CL0bDhvujlyxrbRU3I4 LuFw== 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:user-agent; bh=6fUmvSDmEjz08XKF0ToKqbVBrxXVRyHjyqapg2MBg6Q=; b=NvLHYP6xwAhdCp61XzAwVw1+L8FZHuacyCOMO1H3Ntdg4v+6iw4He9BUGHITZO/Vsq doVdAPH5plf7Fm90sivoanz89XYGpshzErwnAIcYwTH7tz5hfsDCINYzfQbZ8+Hm6g0I Ts6BVNYOn2e4ahT8IDvq+biMZPnf7JORSVU8cDIlaOKGXaOWvxO0IvjSsd79NIcr5iOX xJuBUHbosV0no/KdkaexLThz0wY645dl0m+fndkEjKgzTLjoD/j7ccLsFeNDFoQDoQIT d/hpMC1vOqcH8xuwYWLU/NY0slTTBvtl6vuY0zGOuXq48tT73Zhy97GkPvMpXXRPaZrn rq6Q== X-Gm-Message-State: AJcUukfzaJkDOiN/21xi3x0Q0071KG3R3NRuyFLziFTNqPkxW0lUN1A7 HcjkZBHGaZ//zCc6MoP9KXvOKA== X-Received: by 2002:a81:b653:: with SMTP id h19mr22487323ywk.170.1548712396677; Mon, 28 Jan 2019 13:53:16 -0800 (PST) Received: from localhost ([2620:10d:c091:200::5:42c8]) by smtp.gmail.com with ESMTPSA id u4sm24465788ywu.92.2019.01.28.13.53.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 13:53:15 -0800 (PST) Date: Mon, 28 Jan 2019 16:53:15 -0500 From: Johannes Weiner To: Tetsuo Handa Cc: Michal Hocko , Arkadiusz =?utf-8?Q?Mi=C5=9Bkiewicz?= , Andrew Morton , Tejun Heo , cgroups@vger.kernel.org, Aleksa Sarai , Jay Kamat , Roman Gushchin , linux-kernel@vger.kernel.org, Linus Torvalds , linux-mm Subject: Re: [PATCH v3] oom, oom_reaper: do not enqueue same task twice Message-ID: <20190128215315.GA2011@cmpxchg.org> References: <6da6ca69-5a6e-a9f6-d091-f89a8488982a@gmail.com> <72aa8863-a534-b8df-6b9e-f69cf4dd5c4d@i-love.sakura.ne.jp> <33a07810-6dbc-36be-5bb6-a279773ccf69@i-love.sakura.ne.jp> <34e97b46-0792-cc66-e0f2-d72576cdec59@i-love.sakura.ne.jp> <2b0c7d6c-c58a-da7d-6f0a-4900694ec2d3@gmail.com> <1d161137-55a5-126f-b47e-b2625bd798ca@i-love.sakura.ne.jp> <20190127083724.GA18811@dhcp22.suse.cz> <20190127114021.GB18811@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tetsuo, On Sun, Jan 27, 2019 at 11:57:38PM +0900, Tetsuo Handa wrote: > From 9c9e935fc038342c48461aabca666f1b544e32b1 Mon Sep 17 00:00:00 2001 > From: Tetsuo Handa > Date: Sun, 27 Jan 2019 23:51:37 +0900 > Subject: [PATCH v3] oom, oom_reaper: do not enqueue same task twice > > Arkadiusz reported that enabling memcg's group oom killing causes > strange memcg statistics where there is no task in a memcg despite > the number of tasks in that memcg is not 0. It turned out that there > is a bug in wake_oom_reaper() which allows enqueuing same task twice > which makes impossible to decrease the number of tasks in that memcg > due to a refcount leak. > > This bug existed since the OOM reaper became invokable from > task_will_free_mem(current) path in out_of_memory() in Linux 4.7, > but memcg's group oom killing made it easier to trigger this bug by > calling wake_oom_reaper() on the same task from one out_of_memory() > request. This changelog seems a little terse compared to how tricky this is. Can you please include an explanation here *how* this bug is possible? I.e. the race condition that causes the function te be entered twice and the existing re-entrance check in there to fail. > Fix this bug using an approach used by commit 855b018325737f76 > ("oom, oom_reaper: disable oom_reaper for oom_kill_allocating_task"). > As a side effect of this patch, this patch also avoids enqueuing > multiple threads sharing memory via task_will_free_mem(current) path.