Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2495300rdb; Mon, 20 Nov 2023 12:24:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTO7qsQZksrA7A8y5TO8OkdqdVUArHdNcgjL1wgvcfzz870xeaXVYCkbGxaGS4hdBga51L X-Received: by 2002:a05:6a21:999e:b0:188:f1dd:62aa with SMTP id ve30-20020a056a21999e00b00188f1dd62aamr7006449pzb.44.1700511854267; Mon, 20 Nov 2023 12:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700511854; cv=none; d=google.com; s=arc-20160816; b=LZqIiS3pIfPAcgPZBHph22NHTzEvnusvrndPx0W+lswS7cOgP6DJtLIyKtjtqFdUOX Bk/IlNA1GagjKmKuAbDMBr4Hq2+l+ZwfALIZtxZ02KP/cObpsStq0SJKieQ1Xe+pqBfl OaatZrDFm/ep/D7dNA32E0B0ayOTKjF0w6jbolKSs7SkkNzWxHQcahEuPB5Wsn0iNCoj Oq/CXKviNqK2J/jP59qnZx3WpRM7SYaryfKhJJh5n8XsIHcvp4qeO2VD7CkcDtOnY9QK aov9BtZTZwxZcn+5YiTlVF8e2blOvQng5OG/4KwLil/8ag/dilw2qGYowSP6pKRPP4LI ZxxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NFg0wlSr/v/kErEOyhobnwmAmvgCu5Yu1gdKePoxtJQ=; fh=7/oIA1hohJOIEf6z/fT1l7guGNHBrqen98VhZ2KvRCQ=; b=dkJPtW3/SaSutYe3q5nD/VNzNIJoBj7d+hQhvfBvaaOIwV3wGUmrQ0V8Nbc9fKBrtp An7yhN+6axQpswbGwX+kZuIaOJf++Dphz34PbCOzXxCcqNlpms3xxDCnB9LvsGDUSj75 xJ1A1eb4waUoDu3AvT9CaLUsPWtsz4I1qLrX+SOV3nzlF3tfMSCvtijskLhZW2NlqDPM Jf9QTYeXOQSU6ca0FiKlKrFnaYQmGZAO+xtorKjmxzJ+yB+CvIl1bNu8PdMEQUXqeDL0 Cm0WLYIXmP7xvIXTwS3AeeKZDqdkIT90L5gqDow6ogSIpuDFYoYKWHjwSNLtSUQCS61b YgIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cJSYvudJ; 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=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j4-20020a056a00130400b006c4ad151a62si9057169pfu.266.2023.11.20.12.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 12:24:14 -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=@kernel.org header.s=k20201202 header.b=cJSYvudJ; 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=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 10DB6802E3C8; Mon, 20 Nov 2023 12:22:58 -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 S229780AbjKTUW5 (ORCPT + 99 others); Mon, 20 Nov 2023 15:22:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbjKTUW4 (ORCPT ); Mon, 20 Nov 2023 15:22:56 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32631CB for ; Mon, 20 Nov 2023 12:22:53 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E161C433C8 for ; Mon, 20 Nov 2023 20:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700511772; bh=gIgqR/9VcuTYBSkml6AkfzkkEsnD1KQBGwRnh+jZD2U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cJSYvudJ73nVPGMLTsPa0tmWSiq0m7uJ8URX3gFum2ENVm5MjARlAtnKSfWFmgMjY xOHhg9SCtmXslK3vqF+uvvUFWLrazsmFY/gv1jmQGTkDXOsFdYQfuo100i+3xOQP3q yMzCvLmapw6u8tIM/bLdyXSp/+YKrrUBHIaFPufmfSecGNFkvbrKPZZkMzOeiHkzV4 Hks2YHQ+TW33yNpF5ABTV5wU2Ox9gZKsWEqBAZZAMkkxV+H1irYmHFHoIkEWERlNbe Mi3zBdbo+q8hr1v2HiPetVfl4EhNTh+UcetcLrqengyjX+zGNUH0nwFB9RYPwfCBgB l5Mhg+eleOIeQ== Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-285196aaecaso1192184a91.0 for ; Mon, 20 Nov 2023 12:22:52 -0800 (PST) X-Gm-Message-State: AOJu0YyJ4aVloYNfSW1xtV7ywbs3Mv6PkFoJ3UKV8BZq4dhK19a5M/h8 V8ZmYVCnTo+41f8k0kO5JT27AqypUN8KXW/ugtzQaQ== X-Received: by 2002:a17:90b:4d0d:b0:27d:c36:e12d with SMTP id mw13-20020a17090b4d0d00b0027d0c36e12dmr6456816pjb.6.1700511772129; Mon, 20 Nov 2023 12:22:52 -0800 (PST) MIME-Version: 1.0 References: <20231119194740.94101-1-ryncsn@gmail.com> In-Reply-To: From: Chris Li Date: Mon, 20 Nov 2023 12:22:40 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 00/24] Swapin path refactor for optimization and bugfix To: Yosry Ahmed Cc: Kairui Song , linux-mm@kvack.org, Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_PASS,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]); Mon, 20 Nov 2023 12:22:58 -0800 (PST) Hi Kairui, On Mon, Nov 20, 2023 at 11:10=E2=80=AFAM Yosry Ahmed wrote: > > On Sun, Nov 19, 2023 at 11:48=E2=80=AFAM Kairui Song w= rote: > > > > From: Kairui Song > > > > This series tries to unify and clean up the swapin path, fixing a few > > issues with optimizations: > > > > 1. Memcg leak issue: when a process that previously swapped out some > > migrated to another cgroup, and the origianl cgroup is dead. If we > > do a swapoff, swapped in pages will be accounted into the process > > doing swapoff instead of the new cgroup. This will allow the process > > to use more memory than expect easily. > > > > This can be easily reproduced by: > > - Setup a 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. > > > > I guess this only works for anonymous memory and not shmem, right? > > I think tying memcg charges to a process is not something we usually > do. Charging the pages to the memcg of the faulting process if the > previous owner is dead makes sense, it's essentially recharging the > memory to the new owner. Swapoff is indeed a special case, since the > faulting process is not the new owner, but an admin process or so. I > am guessing charging to the new memcg of the previous owner might make > sense in this case, but it is a change of behavior. > I was looking at this at patch 23 as well. Will ask more questions in the patch thread. I would suggest making these two behavior change patches separate out from the clean up series to give it more exposure and proper discussion. Patch 5 and patch 23. Chris