Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3419163rdh; Mon, 27 Nov 2023 13:57:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEqMMvJvPPW2ig9vv6nQj6ditvWV2VQa+tdPzrlo/zebl0Uc/BIRwQ+BrcwTVnkwHvFNVL X-Received: by 2002:a17:90b:4aca:b0:285:ada5:8d56 with SMTP id mh10-20020a17090b4aca00b00285ada58d56mr6689077pjb.19.1701122234323; Mon, 27 Nov 2023 13:57:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701122234; cv=none; d=google.com; s=arc-20160816; b=lRqLDMfkXZMUlYQO72Den/Y8ZGh+wOmPcDRnnOu2FS0z57+0zC8cJcHpbefQTLfNDE GGDxBowuZwjj7THTk7s2xp/MZnqujJE7/wfbnepHFq3AhRRs8R6SNmauBf23oTDFkhns r0Yy8qHp/lTSUvknORV7lbXZ77s9zIDFPDGfJwmuyf0ZDc34t2DbD4pY30Ui7XlXxtIr igF7J0Yoj64xCba6iIG7myk2YwLDc57y9m0kR4NaHwRkbPu/tKfeiW1BviJXnQDVczaA l6bMjOWbqAnMiaRBJzjSzXeU/UW6Vy3809BkYNNp/yQaFZ4R7iMh0X6dT0byQL7ABo25 rsqQ== 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=m0MzoXczE2pvdHgF1zgI5abaXqlolYZSijKABG1fsdo=; fh=lqF/bUf5cl7GrfQ0s7n7wth9L/4ldBLyZImpnmq3Qnw=; b=r87JN/UI7ezjbXShArLu/T/pZtPbqeivm6CtQI25i8W8pY16JNoLKsvV8xjmrSEKHD Ce8mJdNhFT/hfgLneWxCDhnHJT9aXm9vaCfL8iqgaTB8O3ho97WZzcRQeBb9RJmJ0WV/ LtOduu9bD97iR+FrSO9y2I6SFilKUuxPJgJe82qP97QRTQttUks1GvozbkJvyrNb0T5j WFqQ2G6wOTunkA5EbwD3iLAVGs/gUdu2Fwib3M40V9WsXPNQ07PwtBBMT53GOA5LEHF1 lIA+UpvlCiH5ApG6wEJlkHsustb/rHGUqUxuUNc/FpS6efY3DPhC7J8JVGf5e7LUaCob KkdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rsDPBhCa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id my7-20020a17090b4c8700b002774ecb2ecdsi11720526pjb.19.2023.11.27.13.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 13:57:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rsDPBhCa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 06E5280FF027; Mon, 27 Nov 2023 13:57:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233172AbjK0V47 (ORCPT + 99 others); Mon, 27 Nov 2023 16:56:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233421AbjK0V45 (ORCPT ); Mon, 27 Nov 2023 16:56:57 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA846BD for ; Mon, 27 Nov 2023 13:57:03 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-54b18c9b21bso3250450a12.0 for ; Mon, 27 Nov 2023 13:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701122222; x=1701727022; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=m0MzoXczE2pvdHgF1zgI5abaXqlolYZSijKABG1fsdo=; b=rsDPBhCajJDoYdYzuuGIjoQnbm3K2sFJ6429HQPVu3l0rGpEJY8MsLwn2B7+y31s6z opz2jt2Yw0gKuF6N5ncaSEOB6m+Dbn2f2LJK2eYPK/I/3NePkjqlYO46qd4fr5A8KNEh MxFaSi1X0FUx3GJkLd1VD5CVwaggO0qYOERVy9EvCav8g3ApKGi41XjIPK+1LPot3KbC DApz+LYWbD6T6ihqqsF3yfXuuMl+yQKHezracRlHXupSZCpA3JcRLWpCnGdXDJ6B6c8E TjRJFEjqHgsFNvN0kmenHL+y+BkYCmt28EsddtUWxBG/plTjb7kZ22tk4LnfrdVDCfvc ca6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701122222; x=1701727022; h=content-transfer-encoding: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=m0MzoXczE2pvdHgF1zgI5abaXqlolYZSijKABG1fsdo=; b=bilEu9rLXVvANVVGz/5ZYP0ljzFXgkZXOBpWh766hLktUPEDAXhODr85i0qlmnYPZ4 uc1EwOZ09YIVzb3cJGgelOjV7IWRw1mHG6nUnJ2qXCVLycLH9mjpDpfO/77p/avcIH0H AmnxrcbJtDSADyp7dZr7NQIvhPdGgX3u6V90A9spLGwMZTff66lGXmytataaUTUEuQr4 m41qjHoSdDQWK3BJqaDhHlBvPVpM2bMaejUZ4b3pZJ2sP9VMUQJXZKI/s2UkuTDLU32N 8FxQJ3mM7zs2NpmpUlfCWyX8kuXfd81H7ud9YF1zRkskNIDhAVf4+zO924BvJj/kNi50 dQxw== X-Gm-Message-State: AOJu0YzwfVo9mLvTzZFth3ioAYt0WKUUscZiYUldRX0WVrNBEjDnDehg umW/5sxfRWJsWbQnjhcDZCIJKgXO0zcE0CNsMSp4kg== X-Received: by 2002:a17:906:1083:b0:a09:e7bf:127a with SMTP id u3-20020a170906108300b00a09e7bf127amr7840196eju.67.1701122222013; Mon, 27 Nov 2023 13:57:02 -0800 (PST) MIME-Version: 1.0 References: <87msv58068.fsf@yhuang6-desk2.ccr.corp.intel.com> <87h6l77wl5.fsf@yhuang6-desk2.ccr.corp.intel.com> <87bkbf7gz6.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: From: Yosry Ahmed Date: Mon, 27 Nov 2023 13:56:26 -0800 Message-ID: Subject: Re: [PATCH v10] mm: vmscan: try to reclaim swapcache pages if no swap space To: Minchan Kim Cc: Chris Li , "Huang, Ying" , Michal Hocko , Liu Shixin , Yu Zhao , Andrew Morton , Sachin Sant , Johannes Weiner , Kefeng Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Mon, 27 Nov 2023 13:57:12 -0800 (PST) On Mon, Nov 27, 2023 at 1:32=E2=80=AFPM Minchan Kim wr= ote: > > On Mon, Nov 27, 2023 at 12:22:59AM -0800, Chris Li wrote: > > On Mon, Nov 27, 2023 at 12:14=E2=80=AFAM Huang, Ying wrote: > > > > I agree with Ying that anonymous pages typically have different pa= ge > > > > access patterns than file pages, so we might want to treat them > > > > differently to reclaim them effectively. > > > > One random idea: > > > > How about we put the anonymous page in a swap cache in a different = LRU > > > > than the rest of the anonymous pages. Then shrinking against those > > > > pages in the swap cache would be more effective.Instead of having > > > > [anon, file] LRU, now we have [anon not in swap cache, anon in swap > > > > cache, file] LRU > > > > > > I don't think that it is necessary. The patch is only for a special = use > > > case. Where the swap device is used up while some pages are in swap > > > cache. The patch will kill performance, but it is used to avoid OOM > > > only, not to improve performance. Per my understanding, we will not = use > > > up swap device space in most cases. This may be true for ZRAM, but w= ill > > > we keep pages in swap cache for long when we use ZRAM? > > > > I ask the question regarding how many pages can be freed by this patch > > in this email thread as well, but haven't got the answer from the > > author yet. That is one important aspect to evaluate how valuable is > > that patch. > > Exactly. Since swap cache has different life time with page cache, they > would be usually dropped when pages are unmapped(unless they are shared > with others but anon is usually exclusive private) so I wonder how much > memory we can save. I think the point of this patch is not saving memory, but rather avoiding an OOM condition that will happen if we have no swap space left, but some pages left in the swap cache. Of course, the OOM avoidance will come at the cost of extra work in reclaim to swap those pages out. The only case where I think this might be harmful is if there's plenty of pages to reclaim on the file LRU, and instead we opt to chase down the few swap cache pages. So perhaps we can add a check to only set sc->swapcache_only if the number of pages in the swap cache is more than the number of pages on the file LRU or similar? Just make sure we don't chase the swapcache pages down if there's plenty to scan on the file LRU? > > > Regarding running out of swap space. That is a good point, in server > > workload we don't typically run out of swap device space anyway. > > > > Android uses ZRAM, the story might be different. Adding Minchan here. > > Swap is usually almost full in Android since it compacts(i.e., swapout) > background apps aggressively.