From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51A35C433E6 for ; Tue, 1 Sep 2020 15:04:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EAA21206FA for ; Tue, 1 Sep 2020 15:04:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="yf2xWWvk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAA21206FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 66F116B0092; Tue, 1 Sep 2020 11:04:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F7F76B0095; Tue, 1 Sep 2020 11:04:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50D7E6B0096; Tue, 1 Sep 2020 11:04:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 37CBA6B0092 for ; Tue, 1 Sep 2020 11:04:27 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E06E33655 for ; Tue, 1 Sep 2020 15:04:26 +0000 (UTC) X-FDA: 77214813732.21.sort24_0015a6327099 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 7215C18043646 for ; Tue, 1 Sep 2020 15:04:21 +0000 (UTC) X-HE-Tag: sort24_0015a6327099 X-Filterd-Recvd-Size: 4560 Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 15:03:05 +0000 (UTC) Received: by mail-qv1-f67.google.com with SMTP id m14so655083qvt.1 for ; Tue, 01 Sep 2020 08:03:05 -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=T/8QQxfRNWVbHh3N1oU03SScHQ8EoNypCNrLbEpRHCSm2GihoDiM6yblKNzgGA2tsW 2L6Go8BzZkKOY/lb11nRGAoWgPUP5i+qd1cxP/ARMtCcQZE57pRHPasTuuybh2LOL/Rc i4vs8XNm1sjkuGyxDvpjE0TvYCdtKxThMLVpYeSevrqi6uGwDdrG8YRMRgxxi3rXINvy C6tv13fLj4RsVFUWrA+M4HE1P41N5CZtF05mAKtz7+blLN5kCni13imUUk5lSPpV1xza fczD0W6p8YMMnhACrCkYvDPn6M4wTBQrl0vE3jKftqTuzyaMJwTSm664iDOapue9oxIt 5/jg== X-Gm-Message-State: AOAM530FfsRLOmqHKTrejjP+fOv14H+K2cLNmyCxAKQ0ZZQ6qIS73MsA ulKhQo88U7Soos5Z9+blpDjAri4l+DcXzQ== X-Google-Smtp-Source: ABdhPJwtD/7grvATMu4/sg0JKKjoDM+Eqq34lDdwy3HkegafTZWNtmYCYMELv86LJoXc8FcgmDD6gQ== 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: X-Rspamd-Queue-Id: 7215C18043646 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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