Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5428955rwb; Sun, 4 Dec 2022 21:42:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dbWJPWv4P69/F5XZ/SXZc/+uNQsEzZryWvioMWxAAXyiwG9nhOPy3k1VueC49NQUSbLQw X-Received: by 2002:aa7:815a:0:b0:562:d99c:2f66 with SMTP id d26-20020aa7815a000000b00562d99c2f66mr69499696pfn.42.1670218945273; Sun, 04 Dec 2022 21:42:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670218945; cv=none; d=google.com; s=arc-20160816; b=hp3Jc2v+DuvSBj0+cxaC4VGCBrRK84H2NV7gh+OP2bmsbaO43JNgwzU6TGXWVc3yP3 lN7rLil/StSFFY4YQDK6efTbBkvNEPArCbV3r6NZhOv8blV/sB0F+DND+IlDFIo3Hbyb oiPJsPxnjTzzbx0iAVZOZ/4pEDm9yAKVrHEkySFnSIJ4bBsVoZVcYzZQ99tmFHHOE6KO M7kjXvp6fDhtPwfQIvB3ih3nnKe9nZF2zo0ki01M/7V/zLbxqngDpPKHdGlB6RkRhbV1 i00acaabbwdns0cm26IccWdomYtvqei2Z+uAk3Bzp6tydVL68RvRl8e78hG4UkwAN39s p/9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CDW880diX7mHRZdhC0FMBpf8ZaAd6FKghQ3113HgW4I=; b=eB7kBDegUUdMGx5HH5eA8CyWW4arbI12y/yVFHp+iRml4qqYbfSAe6F+0GeLvseObt PJ6vs+BspxT4utM4rOo/dV2YOy7gQTCPu5fF0jne6b55i6gbxkbiRDD2HRv+ClztiduD yJUZWYfSniO4Axs6SuPV5sXu8vi41cid6wHwBFordv15LIgcNgNrjP/iFEA2pvdQxU4z 1JYpPe1cMZYIRYx/4729vUt6BBu3EttpqILtTc4M+MsLF3qImm+vJh0wkBBMkAL2qPjC wcYCU+YeNyX5xlQxkgczAOr3uJFvhx4zvPKzait3WirsYt2Yf3HShQUlzQ6BXqsqZCCV QrbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=HZsN7G7Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v12-20020a17090a4ecc00b001fe41707a2esi15829104pjl.90.2022.12.04.21.42.15; Sun, 04 Dec 2022 21:42:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=HZsN7G7Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231436AbiLEFEK (ORCPT + 82 others); Mon, 5 Dec 2022 00:04:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbiLEFEH (ORCPT ); Mon, 5 Dec 2022 00:04:07 -0500 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAEF713D6C for ; Sun, 4 Dec 2022 21:04:06 -0800 (PST) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-3c090251d59so106747527b3.4 for ; Sun, 04 Dec 2022 21:04:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CDW880diX7mHRZdhC0FMBpf8ZaAd6FKghQ3113HgW4I=; b=HZsN7G7YvTSC26S5K6Yc3T/p6JpRuK7WTPsGnqOVEkU67s3G9u58fjA0Ju52+XQPee 0wtlIqpD29Jb5oMkjmUw7r4PTbkUHz0zGYsrBrbebm1Hnznf6dpL/Wu2aZoUxTnZfUE5 YOpz+AK/fiqDRVlAul2Qw4w2J3vh+q7jYnVI7OSGxj2q5cGMAFfrmn5OoaYaqkee77me JsLJnN8tX0ZfqKRhGfrd7+3h7IZ/SeUaNkNBsd8iq6UU0LGqo511zTMNjDAq5Fsg+Llq ASQxILTct11B2nBufTkQkHPC1tKLpaY1u4/oFFv94244gH2c5babP+gj7eeuna705F5/ TWiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CDW880diX7mHRZdhC0FMBpf8ZaAd6FKghQ3113HgW4I=; b=S0HUTln1DXN+aZWSdbi77hBOishJBVQR8nk7R8dffTDMsG6T4mKPNfm7SApw4fcYxq QR5I6WQ+6R51gfqeyGcEhO3mVoqh+QbuYamhZLYlXy2yjSwxhBIaei+ahXVydHq1BkmO I9G4rra9bgkrs/HwRpM4PisfBj8DxJhIop/pjsVS2zpoKasvADwzSViEvGbY9FTPDGaf mhAvxTKyKAK1ZvBKmOGLt8h2SXRjzALqHJrYYn2ILYXHIIxmY1pJuXpX4GNCNRL5on4T aVozyigQGypEQdzubhaBGtItmB9kNRgb9FLU4ZHOQh1aRfy+YmlbZMAOxWnUOQ1SCv43 HS+w== X-Gm-Message-State: ANoB5pmSLjIXgrrTZ6yPTuUDBvlZovONaVx+5fGofvoUjPDhymuSQ2wu ynrv8fndnJCay8yXcuRyLMhIt3cvAk4GiUtlK8271A== X-Received: by 2002:a0d:d5ce:0:b0:3ba:29f1:1ddc with SMTP id x197-20020a0dd5ce000000b003ba29f11ddcmr42585153ywd.311.1670216645962; Sun, 04 Dec 2022 21:04:05 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Shakeel Butt Date: Sun, 4 Dec 2022 21:03:54 -0800 Message-ID: Subject: Re: [PATCH] mm: memcg: fix swapcached stat accounting To: Hugh Dickins Cc: Andrew Morton , Michal Hocko , Roman Gushchin , Johannes Weiner , Yu Zhao , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 4, 2022 at 5:01 PM Hugh Dickins wrote: > > I'd been worried by high "swapcached" counts in memcg OOM reports, > thought we had a problem freeing swapcache, but it was just the > accounting that was wrong. > > Two issues: > > 1. When __remove_mapping() removes swapcache, __delete_from_swap_cache() > relies on memcg_data for the right counts to be updated; but that had > already been reset by mem_cgroup_swapout(). Swap those calls around - > mem_cgroup_swapout() does not require the swapcached flag to be set. > > 6.1 commit ac35a4902374 ("mm: multi-gen LRU: minimal implementation") > already made a similar swap for workingset_eviction(), but not for this. > > 2. memcg's "swapcached" count was added for memcg v2 stats, but displayed > on OOM even for memcg v1: so mem_cgroup_move_account() ought to move it. > > Fixes: b6038942480e ("mm: memcg: add swapcache stat for memcg v2") > Signed-off-by: Hugh Dickins Acked-by: Shakeel Butt