Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1168840pxk; Mon, 31 Aug 2020 11:40:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHo0IwltjRJWhmhLDRbaag5UA14DI3Xx54Moq0Gy6aS9fOI0SPeysWfeWbR4JGML9p7TBc X-Received: by 2002:a17:906:4e03:: with SMTP id z3mr2119669eju.503.1598899229412; Mon, 31 Aug 2020 11:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598899229; cv=none; d=google.com; s=arc-20160816; b=KkrhDSK22W1NKn1dPwoeh2YMmMSb8kxUwq3g3ZbDV5nwKdLlo601SszZgcPljXLb4V 7xsnr5ZIv7/TC7pIgOTDrMTNqM9jR9v2W4PlNgOmQTHJhoqKMx1mxkDYaFirw5FKxV5Q UclYh9a7EM44/xXBGUTc2p6x2021hbOPVAIcmZgRE7L0ox4/luj5gJazwb0XsfdCKgtZ xNDxBpsYhTr5Tw7E1fOk38q/7rgXQpo9IrGP32CnnbzV6qe+LUdWgrKo86F43g4fCKB5 pmcxUh16nkzsJDZ07CUMiiLlhI342E8Zmub7hlT/3TeFp177zoX5JfLSc0TYXyPqxhjH a1WA== 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 :in-reply-to:references:mime-version:dkim-signature; bh=uPSqj5hFIPGTyO7lh981GDp+TXnOtHBASn3RvL7Epes=; b=Mz0Sq7EHb6X9/tqx1/8/tAoE37ft+BpklaEDHSAv7CwTRqH4sv0f2WYAyR9C7WJDHs FfIvwlH1CLKyzdXGyxeLazvUeclqZXHQnR+Ut2S9g/4YzDvsSfKSi23OJwq23BhCVsko xafi11rYV6XxtsEEHDIEAZuiE98/FXbozbLsEuf6dkLCP0mkwt9/58NAr+oMYedRSJdh PmnehNxF4gtNiK4Qa68LhQp2vlrnCMhgCErjGXYvpdF72rhpdT3L6Okbabmy3bF2lR7T 0NVl+UxRxMVvnsBLHKoZLVzDMChqy0LsmAf8NqB+JupKBkO2bin5qu1pn3CgD9cAnDDn VosA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SeXPIm+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id nr20si3194550ejb.483.2020.08.31.11.40.06; Mon, 31 Aug 2020 11:40:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SeXPIm+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728036AbgHaOkb (ORCPT + 99 others); Mon, 31 Aug 2020 10:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbgHaOkZ (ORCPT ); Mon, 31 Aug 2020 10:40:25 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F55C061573 for ; Mon, 31 Aug 2020 07:40:20 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id k25so3976676ljg.9 for ; Mon, 31 Aug 2020 07:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uPSqj5hFIPGTyO7lh981GDp+TXnOtHBASn3RvL7Epes=; b=SeXPIm+AHj0Qf+3vNfhXciscqUdpDnei3CTwlmJ3ECw+JJX62FZGyZj34aJbxF7MHT A7t6pHhnVdftJTMq/p3NFn6gNaqNb9bp4eg47QKNZveAf9BB3De0o8nrD3u8FtYU5LwF roK2Zbvn8/jO2c8Wk0lHgVBDxhWFxXS4/8sOU/JXCcI+5QlBrOu0dbKspkGoDqklfmJl OzWlofbJasZYGNIkUZMK6hGOVqYJrjpKx2C/8jOuR91QjD32jia8+NH+cInBQjcWeVMk ogfwev8Aq6R1byneK54x81HVJD0zI6VrtqGL3n4q55KYXjaZtYVSezvabxhm122BhczJ 7dPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uPSqj5hFIPGTyO7lh981GDp+TXnOtHBASn3RvL7Epes=; b=BvhMHYsn3/T5OAxNU5DLvoYERGSmknUj/MkNUQM16NAuYm/SQ6401cJxJ81HKcXESq y+y8T6337+LJ8XwgvpXYBuwQ3ghJNWBcLs5GqMy7/fEx6cTuf0e1Xi+cS3AlC0b0UVDt ve0tocu7WWqVi/vqhY3bKD9PNhsDQ9GLMzUmOZFaUmwiU3DOLkef+GdlGz/QLa9sfvJb jHRmmD1Qoy1MOwH7LmbqouDfhBjAfhOM2jciPCZvzl/qLrlj0uRMDkI4pWQ3YkLqVgbC p+YHFpjjjt0pgkIqMswiJC4VL8nngl6KzzS5IhIBB7c3PYk7QzdQAuLOl3KF8gauFn7D VJyg== X-Gm-Message-State: AOAM530DFmxZtmCa5Efbea87xsFY5a5CBZK51pKB0WJwdZToJCuq7ifD Bz09NVBmMHTSJV4eynNAtTlAwmYYkszX6Y2/U2Hf7g== X-Received: by 2002:a2e:96c3:: with SMTP id d3mr859612ljj.270.1598884818405; Mon, 31 Aug 2020 07:40:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shakeel Butt Date: Mon, 31 Aug 2020 07:40:07 -0700 Message-ID: Subject: Re: [PATCH 1/5] ksm: reinstate memcg charge on copied pages To: Hugh Dickins Cc: Andrew Morton , Alex Shi , Johannes Weiner , Michal Hocko , Mike Kravetz , Matthew Wilcox , Qian Cai , LKML , Linux MM 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 Sun, Aug 30, 2020 at 1:59 PM Hugh Dickins wrote: > > In 5.8 some instances of memcg charging in do_swap_page() and unuse_pte() > were removed, on the understanding that swap cache is now already charged > at those points; but a case was missed, when ksm_might_need_to_copy() has > decided it must allocate a substitute page: such pages were never charged. > Fix it inside ksm_might_need_to_copy(). > > This was discovered by Alex Shi's prospective commit "mm/memcg: warning > on !memcg after readahead page charged". > > But there is a another surprise: this also fixes some rarer uncharged > PageAnon cases, when KSM is configured in, but has never been activated. > ksm_might_need_to_copy()'s anon_vma->root and linear_page_index() check > sometimes catches a case which would need to have been copied if KSM > were turned on. Or that's my optimistic interpretation (of my own old > code), but it leaves some doubt as to whether everything is working as > intended there - might it hint at rare anon ptes which rmap cannot find? > A question not easily answered: put in the fix for missed memcg charges. > > Fixes: 4c6355b25e8b ("mm: memcontrol: charge swapin pages on instantiation") > Signed-off-by: Hugh Dickins > Cc: stable@vger.kernel.org # v5.8 Reviewed-by: Shakeel Butt