Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1800480pxk; Tue, 1 Sep 2020 08:07:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7bX8DEoj06Ona5WzvsawqglpAFXbFdxQLsMgy+NVb8J+dG7dP7R0py673ehEbaUwGq4l1 X-Received: by 2002:a17:907:9c3:: with SMTP id bx3mr1884935ejc.164.1598972865160; Tue, 01 Sep 2020 08:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598972865; cv=none; d=google.com; s=arc-20160816; b=GKQuW3NAWbzuEL9s13IHXdqK/w9MkDs8SwMnBh9trkNgeq5y3cJ7pE+QM7CMlMSH6R KwSzCxcB76sCcPERsmx4d9gBnylBipTiGD/iQMIZ3VBJ65yrzdBea4Dd0okAffQzfBSo IXjcCdpkjk7WLrxnELz6sohVYNJCrXkNHnkw+xYZ8+Ldwe84Dz/uxi7/J4yuEq8bIrIq RsQUCnYqVo+u8i7M5fpLWI+mwCu5FBmh5fsc/rehRhJqrdQb/Samcn9LUtXTelbOIO+3 JksDKfwRrTAEGyIfmNfSskW5mOVIoXsOfzTqYWY/cjJlll49ncFniOsOib4PjXndc19v 7HFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=7hamU6hh70qynnTiDqdZnxkwA4lZpFog+JwYUlEr/IU=; b=rWANqP6W8r1Z2U5wxUGTXmH4kiugghxUVQrtUvrrOZ4eYNyZ67T4a1ptzXAGnbI+0O PkISow4x/byjSh2cuXfJf+9rD0/uRUK+c/njKFng66L+IEKOh3luOJds3AJojoi9NmcX +hRMfHRZjkMkTSt0oeUUnt5+tGhGvntH4OioUC2odk4E/t40PJY65vwO0sMPVs3KIvmV LpRjm9+RAWXP9XRxAAeedq+R2eyT7OF6pIVReCtYqEiBhD8g8RU2FV3ReLOqpyVVzFMI XuyEUnfQcl+F31jBZQNLMEkGPdtypJjAm7ZBlmRDYrc0Ue43KNyhI7Aw0Y9C9E/PgeYq +dBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=yf2xWWvk; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si694875edr.280.2020.09.01.08.07.20; Tue, 01 Sep 2020 08:07:45 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=yf2xWWvk; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728452AbgIAPDO (ORCPT + 99 others); Tue, 1 Sep 2020 11:03:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728386AbgIAPDH (ORCPT ); Tue, 1 Sep 2020 11:03:07 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F6FEC061244 for ; Tue, 1 Sep 2020 08:03:06 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id b13so650686qvl.2 for ; Tue, 01 Sep 2020 08:03:06 -0700 (PDT) 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; bh=7hamU6hh70qynnTiDqdZnxkwA4lZpFog+JwYUlEr/IU=; b=yf2xWWvk1xRfdDfp5/KDnPzVZmvLVynwUatxUyczMxvoo5qoWCz2qKcQxQU5mFSpxw NhRb12uOylBNsJ1CMLYVSQXaAGWHeX/eo1nS6nEmcUx2UPP93DWSblcZlbXuOZxRW1hQ mHo5vzXl8FzCyzcogsYpiwRXSh5mq4UzkHPeThfBd8DZnkJ8FI+IEPw7F9doDbu0QrIO HR9BQOYBpg2EwPDUPn8el3O4u6N+g7GCcfWVuHk0h1ZFaSA23RnMd7gHXjL3EwbRcCSL RikWYHtdni0MdsfqEjfbdfQ7AqmNItT8xlpt3hJYb4MyUNt07Je4rKAOSAMSAHYaS54p rVwQ== 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; bh=7hamU6hh70qynnTiDqdZnxkwA4lZpFog+JwYUlEr/IU=; b=SH8My7rMv/TvhBh6tZtf66BaoYwLMduWolM8KKu36wYYZWXKFPp5PFjrJpGamuacmr g+r1Y8PnbOIvwGcroSwv81CEVyZnKu16RolkRHSaaioqv80mg4lvhQPNNXVVFzYvG6GZ ymsetNQ4ZGvHW7l5LQOaDHhZh0Uz2McHTlgodvT6vQS9k7BeeuQwT8Psmadl2f1ECWGr cbpl29mDeCRSBYkTgk64XLZuGgomaWZCnbLaF1WiInM7XFvjrxNbwU33+ieTdkQW5ThF kFvmDCtLdxMU0Y4BaZJCt2x0hBrnWeJCoW1LkkVcHxO+rEaYL+Kj6KN/WI/hqbt7WQrF cKCA== X-Gm-Message-State: AOAM532wgAcHynCne3rZrP70Fj10ENsH2nZj4yXutr8ZqAtTHtmVFtGz y7Ewnz1L2gZ0Rs/KaLLWHwf0mQ== X-Received: by 2002:a0c:e04e:: with SMTP id y14mr2200632qvk.117.1598972585297; Tue, 01 Sep 2020 08:03:05 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:fc60]) by smtp.gmail.com with ESMTPSA id s20sm1850047qkg.65.2020.09.01.08.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 08:03:04 -0700 (PDT) Date: Tue, 1 Sep 2020 11:01:49 -0400 From: Johannes Weiner To: Hugh Dickins Cc: Andrew Morton , Alex Shi , Michal Hocko , Mike Kravetz , Shakeel Butt , Matthew Wilcox , Qian Cai , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 1/5] ksm: reinstate memcg charge on copied pages Message-ID: <20200901150149.GA45118@cmpxchg.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 01:59:35PM -0700, 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 Acked-by: Johannes Weiner