Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2250768ybh; Sun, 4 Aug 2019 21:17:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiCZsmeYUqz702U3noVv7OlzXIoY3cUpnvP93WiaphnSNfYUmRGc4VsEVhwEgYoAF7aIw7 X-Received: by 2002:a63:1918:: with SMTP id z24mr128997309pgl.94.1564978637984; Sun, 04 Aug 2019 21:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564978637; cv=none; d=google.com; s=arc-20160816; b=vkYobqPCtLPVJegJY3PfPwWJ5J7q6ObvxamAgddmBpx873PDaTXRrqhD+AVY6hTwl5 WuBsGn83tBsw/FhTEwfWTJSkId9+doygTIJR/6OVpqKkVme4dD3fAeitUSDY/9vLexg7 Hep6ibzPBFmFlhVtLj1FwU4nRxZE8bHmWw5TZCPPtFnl2MjXizt0ecr9k7ZN5pBuq8LO 5P9xiPKN0QtnZGPLm8ceMiHoEk5kthqLQkLyvBE1kI7wnG9VMLxFDW0qXwQcRVO3zxet vKQM5AgR+0YzlHe7HEfYyCthxVkFhL28gx1T4THZIlANuLmNHtsleJOA5sNk3XKR9m2F I57Q== 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=mva09u+yn1RWE+TO1luNzBDnrlH/Q/3QfIfoFJtdBKs=; b=nKo0bjNSfBlXh/7pQ5wRre8ur0GS95Gkwi7cPfhbHzMWzYMyDrv9bHE4iViOOVGjCW dHKC4Q2HEZymX1OWB5WepSNuQgF7iToNjX0phDIgSh//+RxrmZUwW0Y7m//lyZnmxgOu JAfICbPkTBjp/Z60xCMK1T7vGwTVx7wy9RCdpST4JxS2YXHKDsyAm1RPjCDFxSd6q3PT DXFHw6UO4yxmz7F64wVyqGV8j296iQ+qoF6utKb3N77gntROPKEqV6EcLaWvd4EaYGru rpPnP5Ksq0e+NngWbvjRn+OgGRI2FhkBSLoKZSvZWVSUVcQfIeeGFiCHRjbwW/DJSCie 6/6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=lUaKgKHU; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l62si45949876pge.590.2019.08.04.21.16.25; Sun, 04 Aug 2019 21:17:17 -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=fail header.i=@gmail.com header.s=20161025 header.b=lUaKgKHU; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726028AbfHEEOr (ORCPT + 99 others); Mon, 5 Aug 2019 00:14:47 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37414 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbfHEEOr (ORCPT ); Mon, 5 Aug 2019 00:14:47 -0400 Received: by mail-pf1-f194.google.com with SMTP id 19so38910976pfa.4 for ; Sun, 04 Aug 2019 21:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mva09u+yn1RWE+TO1luNzBDnrlH/Q/3QfIfoFJtdBKs=; b=lUaKgKHU3tYV6FVsndghO1nh62VmLyjBz+gnRDFzMtyQSKeK4kyNlKt7pfyVZI5dP0 lCmU53u7ZoMWT0GjNCzqnOSqZsjasDVwlPCqu3E04EBsomGuC5AAi2qOnGX+T6kdDxni dV6o/haUzLnNpKhvlZ15NuuJvVzUEFuORq2wb6M+ExKwYLtMUDhXsmnZ6PSmWyr8PWxE V0kct3Svkq8vUoVZOO289g/Yw0Wqon93UAVktJZ1iuJxKV0PoU8euDaXateelJ7JSx9o f40OBUyRw88R3NWa2O8csPHoyge5AVZZPF8py8aCAYxVK8+Dltiuo2QpqUbwAnXmRmta HM1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=mva09u+yn1RWE+TO1luNzBDnrlH/Q/3QfIfoFJtdBKs=; b=WFh0WRKlDWzimve2a7CqH2ZobNQ8h9xschxkoEBnAk+XcEZr7vT9ESBD0OuWfrB9mM 9a33gP+GyxBhAEcB4ym6qX98U6+Byvt/DcbRPrWlm0p1ANBl/L9WfB87Dc+4rrkffZqX Q3/mUUDotR3Mbm1tU9NMtTJK/4DbWLHuOcBEaozm0lMwnZpoJrGxqE9hE6Vc7aZEebuH srJa9SzGfo4U34RDt/MwzFMU5bAYIN5QUSQrONbhU8R9MIuIqmDD6rqPAauMnPIWj4vf ddEGi2/pBX2V5GsU2gXk+k3Ox+KYILF9eGx9A3hAZpOb/W7mbEPl6rwmvxAfi6L5GF4f X3gg== X-Gm-Message-State: APjAAAVlSJUW857VtOh9A3UPFBFE7MkHiRa0odNryiped9RMhUeyY2YA vX6xm/i/x1G5nhgJy6GqQUg= X-Received: by 2002:a63:7e1d:: with SMTP id z29mr134680099pgc.346.1564978486557; Sun, 04 Aug 2019 21:14:46 -0700 (PDT) Received: from google.com ([2401:fa00:d:0:98f1:8b3d:1f37:3e8]) by smtp.gmail.com with ESMTPSA id j1sm115888081pgl.12.2019.08.04.21.14.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 04 Aug 2019 21:14:44 -0700 (PDT) Date: Mon, 5 Aug 2019 13:14:40 +0900 From: Minchan Kim To: Henry Burns Cc: Nitin Gupta , Sergey Senozhatsky , Shakeel Butt , Jonathan Adams , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm/zsmalloc.c: Migration can leave pages in ZS_EMPTY indefinitely Message-ID: <20190805041440.GA178551@google.com> References: <20190802015332.229322-1-henryburns@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190802015332.229322-1-henryburns@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 01, 2019 at 06:53:31PM -0700, Henry Burns wrote: > In zs_page_migrate() we call putback_zspage() after we have finished > migrating all pages in this zspage. However, the return value is ignored. > If a zs_free() races in between zs_page_isolate() and zs_page_migrate(), > freeing the last object in the zspage, putback_zspage() will leave the page > in ZS_EMPTY for potentially an unbounded amount of time. Nice catch. > > To fix this, we need to do the same thing as zs_page_putback() does: > schedule free_work to occur. To avoid duplicated code, move the > sequence to a new putback_zspage_deferred() function which both > zs_page_migrate() and zs_page_putback() call. > > Signed-off-by: Henry Burns Cc: [4.8+] Acked-by: Minchan Kim Below a just trivial: > --- > mm/zsmalloc.c | 30 ++++++++++++++++++++---------- > 1 file changed, 20 insertions(+), 10 deletions(-) > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index 1cda3fe0c2d9..efa660a87787 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -1901,6 +1901,22 @@ static void dec_zspage_isolation(struct zspage *zspage) > zspage->isolated--; > } > > +static void putback_zspage_deferred(struct zs_pool *pool, > + struct size_class *class, > + struct zspage *zspage) > +{ > + enum fullness_group fg; > + > + fg = putback_zspage(class, zspage); > + /* > + * Due to page_lock, we cannot free zspage immediately > + * so let's defer. > + */ Could you move this comment function's description since it becomes a function? Thanks.