Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4074443ybx; Mon, 4 Nov 2019 07:27:41 -0800 (PST) X-Google-Smtp-Source: APXvYqwFU+q25CMmDaCEUhBeAp4IS5xL14k4X0+MimEYsdWx4ly9pGJSmXzJSQ9Qt7VuQaRZVlna X-Received: by 2002:aa7:c80d:: with SMTP id a13mr30021761edt.59.1572881261422; Mon, 04 Nov 2019 07:27:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572881261; cv=none; d=google.com; s=arc-20160816; b=rBVVkZCQo+vn6Zp/Bx9GdPS4//Qg5dnCIz/UA/6kR12/OdB9g/OxRjjjeojH4E0gQ4 WO1nW16hP8XKoFHdBMTTQtZChRXjRYzjDBoywJdbOOzy5El89O1KH1GDQrZStDzQtha2 IcAG4upBkFSt8BXdBjxALABD/V9dV0nR63bPTOX/6mlW365wS10/idk/d5YTejKo6OBB 6oxfIZrOuxun7eWMYxb/aR+BZIN/3VflQmHOmo17FqRefcX2cl3KENCC9QI7GokAdQye lCdyOjEei+j8D+eKCGZzsB2mj+EBWZ8nJBfomOhxcTDCJuMdrqxyU7ptsPSYf7qyWHxm BgHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YNUjPtCpzm+8vYW330N9vvutohsdZnTurKhkqwxw6r0=; b=yuGFa7cStMqkR2VQGXJVrzJEUmey/vZDEBGkpeXB2dCEWJCd1w9Ty8oH56GKZ3gtGl pSw5x8B4oR8HSV+V4e7DoamQ5fJF/CEzacwbnRzdz+ffOk2jXPv5cKSlOHnGZ8+8sIm3 rvaD5yTJSFVYr9Gu5vKAPh15z0sG1xU6z8BVipb/jaRHOBC11a9d/6YxWOL9kZapSOiF yTXV+gIOsWCl59MFrJUABG6Dv22VzKmXncVNZu+safuoJNhKghL/+ATtyNBft6XTP4iu SudIznv5cQVtjFk6NtxKsvV1CEDjeOLPmIOldzfiQPQX4v8KrGwT78ckeGZSKWrshirq oBMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iPXWE51K; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si8362691edf.79.2019.11.04.07.27.18; Mon, 04 Nov 2019 07:27:41 -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=@redhat.com header.s=mimecast20190719 header.b=iPXWE51K; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729302AbfKDPZd (ORCPT + 99 others); Mon, 4 Nov 2019 10:25:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:37200 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728188AbfKDPZc (ORCPT ); Mon, 4 Nov 2019 10:25:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572881131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YNUjPtCpzm+8vYW330N9vvutohsdZnTurKhkqwxw6r0=; b=iPXWE51KALGFymP16xOvrPVa1aqRsv8ToLNkFI+Uu+9PkrRbj0FQl9jG9EE9kDNUWaezM/ dvHSMGTu4gDzQqBFtjFf4X128+wFkraH5mLNfn+L72uMmYGYS82/GpjBKTb1ToofA2Zy6n JyDUXJsHHCi+4VamQxUZaxEdJN7qWNU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-56-u7TOeLLDNXGARytbqgEOlA-1; Mon, 04 Nov 2019 10:25:28 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62D9E800C73; Mon, 4 Nov 2019 15:25:27 +0000 (UTC) Received: from bfoster (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C472B19C4F; Mon, 4 Nov 2019 15:25:26 +0000 (UTC) Date: Mon, 4 Nov 2019 10:25:25 -0500 From: Brian Foster To: Dave Chinner Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 09/28] mm: directed shrinker work deferral Message-ID: <20191104152525.GA10665@bfoster> References: <20191031234618.15403-1-david@fromorbit.com> <20191031234618.15403-10-david@fromorbit.com> MIME-Version: 1.0 In-Reply-To: <20191031234618.15403-10-david@fromorbit.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: u7TOeLLDNXGARytbqgEOlA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 01, 2019 at 10:45:59AM +1100, Dave Chinner wrote: > From: Dave Chinner >=20 > Introduce a mechanism for ->count_objects() to indicate to the > shrinker infrastructure that the reclaim context will not allow > scanning work to be done and so the work it decides is necessary > needs to be deferred. >=20 > This simplifies the code by separating out the accounting of > deferred work from the actual doing of the work, and allows better > decisions to be made by the shrinekr control logic on what action it > can take. >=20 > Signed-off-by: Dave Chinner > --- My understanding from the previous discussion(s) is that this is not tied directly to the gfp mask because that is not the only intended use. While it is currently a boolean tied to the the entire shrinker call, the longer term objective is per-object granularity. I find the argument reasonable enough, but if the above is true, why do we move these checks from ->scan_objects() to ->count_objects() (in the next patch) when per-object decisions will ultimately need to be made by the former? That seems like unnecessary churn and inconsistent with the argument against just temporarily doing something like what Christoph suggested in the previous version, particularly since IIRC the only use in this series was for gfp mask purposes. > include/linux/shrinker.h | 7 +++++++ > mm/vmscan.c | 8 ++++++++ > 2 files changed, 15 insertions(+) >=20 > diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h > index 0f80123650e2..3405c39ab92c 100644 > --- a/include/linux/shrinker.h > +++ b/include/linux/shrinker.h > @@ -31,6 +31,13 @@ struct shrink_control { > =20 > =09/* current memcg being shrunk (for memcg aware shrinkers) */ > =09struct mem_cgroup *memcg; > + > +=09/* > +=09 * set by ->count_objects if reclaim context prevents reclaim from > +=09 * occurring. This allows the shrinker to immediately defer all the > +=09 * work and not even attempt to scan the cache. > +=09 */ > +=09bool defer_work; > }; > =20 > #define SHRINK_STOP (~0UL) > diff --git a/mm/vmscan.c b/mm/vmscan.c > index ee4eecc7e1c2..a215d71d9d4b 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -536,6 +536,13 @@ static unsigned long do_shrink_slab(struct shrink_co= ntrol *shrinkctl, > =09trace_mm_shrink_slab_start(shrinker, shrinkctl, nr, > =09=09=09=09 freeable, delta, total_scan, priority); > =20 > +=09/* > +=09 * If the shrinker can't run (e.g. due to gfp_mask constraints), then > +=09 * defer the work to a context that can scan the cache. > +=09 */ > +=09if (shrinkctl->defer_work) > +=09=09goto done; > + I still find the fact that this per-shrinker invocation field is never reset unnecessarily fragile, and I don't see any good reason not to reset it prior to the shrinker callback that potentially sets it. Brian > =09/* > =09 * Normally, we should not scan less than batch_size objects in one > =09 * pass to avoid too frequent shrinker calls, but if the slab has les= s > @@ -570,6 +577,7 @@ static unsigned long do_shrink_slab(struct shrink_con= trol *shrinkctl, > =09=09cond_resched(); > =09} > =20 > +done: > =09if (next_deferred >=3D scanned) > =09=09next_deferred -=3D scanned; > =09else > --=20 > 2.24.0.rc0 >=20