Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2047389rdb; Sun, 24 Dec 2023 14:21:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyArRudC0W1Wp5U8h8Ne2SfhppJTlUqx1Y+HMR6EEF2DVrwaI1ZweUWFrfpIsKmENX5Qth X-Received: by 2002:a05:6214:1c49:b0:67f:66d:b573 with SMTP id if9-20020a0562141c4900b0067f066db573mr7630663qvb.5.1703456465862; Sun, 24 Dec 2023 14:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703456465; cv=none; d=google.com; s=arc-20160816; b=j8pXBeGchdVj9Vyg7JjudH9flml4CN5Pajn9q96DiDIyp6eYAglgDx8AUGW+qSn/X8 Qf+dvgaI9HCWYUFV+mCWbrCjQonteOFWBXtFL5+X6h71mo9Cd+mxSRQGg+XzS0CDJHpj yEXb8n0nDf/75Lr83hH4dffx8K21eMa+tGyoB4c5YPP0Ihx5EDoJ4JN8OLDJOsD0hT8i 10fFO/MtkAZS08JEo6VgOs0yoMZ3ziae7QeBmEFpQ64CeDL9ZnLbG2hWbxx35nvKjk4+ CyRC2rimMeP189BIzL9g4u2OSa9Gz94mY+x9UMvT8LqFLgyoVmMYmOtHYW/N3Qi/5cGx F0og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature; bh=7LD140+Xgkenp9ciiR1m/6SC0DrA959WMgfk0mFXyRk=; fh=cFiELFUvY6jO/1gMoDbeBo5aMaJXPX4I2B9kgrQYBpM=; b=Oy1CSvV/xXocMPPJUCYHlX8gDGJsUFI5Rh4ljhZ6Uju068IetLJKM1GUMD9N3JwXNp CKORW04wNXed751uRzsYm9xuT7tqOZvPWtk6vy33w84Mzd9KzF0cXLFYkROYTKmS8HSJ 5kHuxv+/3T5hyIRj1HlajluWshLt6zxdcxJqHiYjDyzgaTRSwIiYyAOLHwn6zX7Z64dD jpLL5gFtjQpu/ozYn74hkfHH/yP2hfzIDarG36NlxryhMgkQRcQSRa2robqPq8wRqP1Y ZumZjzKUDxiKhsJsS/dpDM9j1SuY6/FeKxgIxabMZYf8PsTYHvs9AEwMEFEOQh6+iBr6 qLWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BD6Tj7Qp; spf=pass (google.com: domain of linux-kernel+bounces-10841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a10-20020a0ce38a000000b0067f91bab6dasi7346900qvl.233.2023.12.24.14.21.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 14:21:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BD6Tj7Qp; spf=pass (google.com: domain of linux-kernel+bounces-10841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8AC961C213F4 for ; Sun, 24 Dec 2023 22:21:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BFBF101E9; Sun, 24 Dec 2023 22:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BD6Tj7Qp" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0343BFC1A for ; Sun, 24 Dec 2023 22:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d3e4637853so289455ad.0 for ; Sun, 24 Dec 2023 14:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703456456; x=1704061256; darn=vger.kernel.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=7LD140+Xgkenp9ciiR1m/6SC0DrA959WMgfk0mFXyRk=; b=BD6Tj7QpwYRUdefUv8zKl0C7e9CFmftPhUMZo5Aj1FUCJKANDEV6k8sN3hRPi8ZMRX 2ygeJXRQ5P9l4pVIv/32bn6qJugvq6Qz5FWcHlwfRZaq9j0shlxAwjvwpwHgVCqTbOOo nAaRBJO61naORxYP56peQbDY1eG5oMMbWzUachn//iN+65vtBPGExOVpDxirF/gPg8lZ qvn4E6fWVGZh7cdjo1tM+lsaEfZpzk/4nAqQ0EOImqwlpd8EDsP9XJmok5HlU87hi7dL B6eSVfAsacIXJTKFnNct3WdgUkpcWrso+OsLY3vo+WesDMzQRHtdz7AMLwEJomhUeVI2 EHxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703456456; x=1704061256; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7LD140+Xgkenp9ciiR1m/6SC0DrA959WMgfk0mFXyRk=; b=lc29Rqsbq9cftNMPu3VVk8IGeWenj0CgpXteeNDnn161FmsIjOadogm8mpYWowSKYo CukfK422ixLfP5u4OgAI8UcQk4oKDmmf57K/gjcM3jGYu4KXLbdBCvhKqNCj/zfIs1Qo bBntPmuTN2NYMWfe1hroJjt73rJ94Nc2Wpk6WAjUNvV9tyHDxDDy0ThjrDNkopH7Vl1u QrAhAr+KngSqQgSjQYImstQ3QtI8l7UMiNWubWQcGqIWGP72OqHnN56msMyfADAdLYqX /gQ1idDcLMORYoQDpU/vdRkgH659jvTtLfyckY6JCcDiLnMIyMbwcK/WBjrp1/UaPBDj CGAg== X-Gm-Message-State: AOJu0YzC+onbh0PvhEtyYtgN+QSkcpgZtlTEWL7dBY8C/C2fwBTb3dI2 cNEjdcq4Hx7p6q28LMvqnb3dmT3n6Qm9 X-Received: by 2002:a17:903:41cd:b0:1d4:f4:bd18 with SMTP id u13-20020a17090341cd00b001d400f4bd18mr302116ple.20.1703456456102; Sun, 24 Dec 2023 14:20:56 -0800 (PST) Received: from [2620:0:1008:15:c723:e11e:854b:ac88] ([2620:0:1008:15:c723:e11e:854b:ac88]) by smtp.gmail.com with ESMTPSA id m10-20020a170902db0a00b001d0b4693539sm6947242plx.189.2023.12.24.14.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 14:20:55 -0800 (PST) Date: Sun, 24 Dec 2023 14:20:54 -0800 (PST) From: David Rientjes To: Chris Li cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wei Xu , Yu Zhao , Greg Thelen , Chun-Tse Shao , Suren Baghdasaryan , Yosry Ahmed , Brain Geffon , Minchan Kim , Michal Hocko , Mel Gorman , Huang Ying , Nhat Pham , Johannes Weiner , Kairui Song , Zhongkun He , Kemeng Shi , Barry Song , Hugh Dickins Subject: Re: [PATCH] mm: swap: async free swap slot cache entries In-Reply-To: Message-ID: <7454d4e3-a2dd-0571-5ac1-99e99dabcaf0@google.com> References: <20231221-async-free-v1-1-94b277992cb0@kernel.org> <20231222115208.ab4d2aeacdafa4158b14e532@linux-foundation.org> <0a052cb1-a5c5-4bee-5bd5-fd5569765012@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Sun, 24 Dec 2023, Chris Li wrote: > > > > > > How do you quantify the impact of the delayed swap_entry_free()? > > > > > > > > > > > > Since the free and memcg uncharge are now delayed, is there not the > > > > > > possibility that we stay under memory pressure for longer? (Assuming at > > > > > > least some users are swapping because of memory pressure.) > > > > > > > > > > > > I would assume that since the free and uncharge itself is delayed that in > > > > > > the pathological case we'd actually be swapping *more* until the async > > > > > > worker can run. > > > > > > > > > > Thanks for raising this interesting question. > > > > > > > > > > First of all, the swap_entry_free() does not impact "memory.current". > > > > > It reduces "memory.swap.current". Technically it is the swap pressure > > > > > not memory pressure that suffers the extra delay. > > > > > > > > > > Secondly, we are talking about delaying up to 64 swap entries for a > > > > > few microseconds. > > > > > > > > What guarantees that the async freeing happens within a few microseconds? > > > > > > Linux kernel typically doesn't provide RT scheduling guarantees. You > > > can change microseconds to milliseconds, my following reasoning still > > > holds. > > > > > > > What guarantees that the async freeing happens even within 10s? Your > > responses are implying that there is some deadline by which this freeing > > absolutely must happen (us or ms), but I don't know of any strong > > guarantees. > > I think we are in agreement there, there are no such strong guarantees > in linux scheduling. However, when there are free CPU resources, the > job will get scheduled to execute in a reasonable table time frame. If > it does not, I consider that a bug if the CPU has idle resources and > the pending jobs are not able to run for a long time. > The existing code doesn't have such a guarantee either, see my point > follows. I don't know why you want to ask for such a guarantee. > I'm simply trying to compare the pros and cons of the approach. As pointed out previously by Andrew, this approach actually results in *more* work to do freeing. Then, we could have a significant time delay before the freeing is actually done, in addition to the code complexity. And nothing safeguards us from an exponentially increasing amount of freeing that will be done sometime in the future. The current implementation provides strong guarantees that you will do batched freeing that will not accumulate beyond a pre-defined threshold which is proven to work well in practice. My only question was about how we can quantify the impact of the delayed free. We've come to the conclusion that it hasn't been quantified and there is no guarantees on when it will be freed. I'll leave it to those more invested in this path in the page fault handler to provide feedback. Thanks!