Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2048976rdb; Sun, 19 Nov 2023 23:37:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVGH07yFUPYFS880w+PGH6TIxrzbsMxgd9EK6VG1u3zgAMWucRqbjw6s5k42xNoI9PsdqH X-Received: by 2002:a05:6a21:a5a6:b0:181:a38c:8106 with SMTP id gd38-20020a056a21a5a600b00181a38c8106mr10632811pzc.20.1700465877167; Sun, 19 Nov 2023 23:37:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700465877; cv=none; d=google.com; s=arc-20160816; b=C5sg9AyCFQfOmLnDQf56nCLRqNl5VHp2m8WSmKNfRZyKtYnXM+YzNTAaZ+NDSaOHY2 CA51uGvzWjHk7/aSc9Ze16BH/2gGdNgnvgipWFLFaljURUQo8CgIOBanvxuTFD7f+kaK xatuzCnPemOI50rvZ7Q4j3YkrYUqYmMsH23RlsF0vc1MRX/M3CfNwPJyCAilC1MgAYII 9qCO9hYiH8Z6rBhZCymudo4vam2bMwaPEJOqCuMjv61PAusJ/OOppVMk/yszUvn5Smp3 wGzFFxizqntSRyhpHGW3+9SvNYc2M0usHlIGm3e7ykGc2TcHSGqRxsmQM7gAKOzNNVFk pJ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:dkim-signature; bh=5aaosyrM+CaWyWdiYZaLo9JIlZWBbrYmlm0JTceJe6w=; fh=O7ORaJiTjBuIWREUGxwwEMJW1DN+Cmq8zsoJTLjenOg=; b=Z/2KO8yupgppTq3j3+ozJ6zg6vF8GWjQo03uVHZsH9dnbwSsyOD33ttVRUTWokzaur LbUaJKO7LgF8QMObriNaEDfVc+ehtNha+ZN+PIpmYBHar67HFszMxq8/FoChz1Sp+Gl/ tdMfku4em1Saf3KexWC80oekcJR3xXurDa0KDFHEXOVyNc3Aq/iBckEIvS/uKPFi79LO 26Sm+DTt+dK4XuKpyv3e1MaGOaIczZTVYjyl2MmciqZaED7RrTtTvSI05yJ29uUEp8NN 0KXZdVIxl5eAA8LFplNWYMObr3OhWyoFxg8nGnHx0axmyV5HVwYsJhBYfJBq5NFD0c9Q Af/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FrdvlEwH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id fb37-20020a056a002da500b006cb8daad91csi2164156pfb.187.2023.11.19.23.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 23:37:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FrdvlEwH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EC688805B20A; Sun, 19 Nov 2023 23:37:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231995AbjKTHhP (ORCPT + 99 others); Mon, 20 Nov 2023 02:37:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjKTHhN (ORCPT ); Mon, 20 Nov 2023 02:37:13 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F9C0B4 for ; Sun, 19 Nov 2023 23:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700465829; x=1732001829; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=te/kalXMqxIcUbJWXayxqFbR2ZYuIskBP8WKF0nSXPY=; b=FrdvlEwHxD82tTetB6SXRvC1YkacDQUKQfMiUpia15fi1mNcE3uSGuVg xiQu/NtoAWG1S0ng0idtU9bJ2C7ZjXGS3kgfNqmPTKwncl2AENuLvdAa9 EDl1jx4OBgVXaKdSHS4dbnZfp/ec1cg5D/K9ZflNUKeSsRVrAeiTVbwQF VhoGOrFnDwaDBCRDXkLmSLZlJsl/KdNMHaiole1MJx1KNPtz5WCJzA5uf ik3cufA2xzRyHQ0P1G7gz03nbn0Yv0MTK6r6khCx27MRid/g2Tf7ZX7uh aLq9Xze+q4JGwF6tLvocplHFiQwC4OI/wGFSnPdlGTOLcppMOpdlFy9ly A==; X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="395499560" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="395499560" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2023 23:37:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="742647791" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="742647791" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2023 23:37:06 -0800 From: "Huang, Ying" To: Kairui Song Cc: linux-mm@kvack.org, Kairui Song , Andrew Morton , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , linux-kernel@vger.kernel.org, Tejun Heo Subject: Re: [PATCH 23/24] swap: fix multiple swap leak when after cgroup migrate In-Reply-To: <20231119194740.94101-24-ryncsn@gmail.com> (Kairui Song's message of "Mon, 20 Nov 2023 03:47:39 +0800") References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-24-ryncsn@gmail.com> Date: Mon, 20 Nov 2023 15:35:05 +0800 Message-ID: <87msv8c1xy.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 19 Nov 2023 23:37:28 -0800 (PST) Kairui Song writes: > From: Kairui Song > > When a process which previously swapped some memory was moved to > another cgroup, and the cgroup it previous in is dead, then swapped in > pages will be leaked into rootcg. Previous commits fixed the bug for > no readahead path, this commit fix the same issue for readahead path. > > This can be easily reproduced by: > - Setup a SSD or HDD swap. > - Create memory cgroup A, B and C. > - Spawn process P1 in cgroup A and make it swap out some pages. > - Move process P1 to memory cgroup B. > - Destroy cgroup A. > - Do a swapoff in cgroup C > - Swapped in pages is accounted into cgroup C. > > This patch will fix it make the swapped in pages accounted in cgroup B. Accroding to "Memory Ownership" section of Documentation/admin-guide/cgroup-v2.rst, " A memory area is charged to the cgroup which instantiated it and stays charged to the cgroup until the area is released. Migrating a process to a different cgroup doesn't move the memory usages that it instantiated while in the previous cgroup to the new cgroup. " Because we don't move the charge when we move a task from one cgroup to another. It's controversial which cgroup should be charged to. According to the above document, it's acceptable to charge to the cgroup C (cgroup where swapoff happens). -- Best Regards, Huang, Ying