Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp74715rdf; Mon, 20 Nov 2023 16:57:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgTE/NkgQiEMHZdgmwLCWjN6t2ERReCb0kWdv+rWTEHs1Tm0L3lCry+l9yxsBNp2/du4zO X-Received: by 2002:a17:90b:783:b0:280:29df:747e with SMTP id l3-20020a17090b078300b0028029df747emr1635835pjz.1.1700528239741; Mon, 20 Nov 2023 16:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700528239; cv=none; d=google.com; s=arc-20160816; b=qR2AIkgUjYHlOTzHfY87tZHy6TRHTObi3ZVDRkikwpt1aY3VlSUrKr87yH46JBHrzu Oqk1+o5eQqKWclHkLbmnnvi1SnDwb3jdifL5q/4RkPg69RHjLg4tl0xbn/hBJmc63opr +FI7qU07cY3Ccdh1OSGdsNaou9/+bAJGMro/W3/8ScznKYtv20NX2EGT/x5cgNZ32LoZ 4NnyMUrgF/u9Gv7eOh0iOtG9Cq5WePaMKiE6o5u4+iT6GfxpQxZt4JkNY0KPX6LaSQk6 P2frqlYsBiCcWPdHCXbd+2hW25BLEgfh+YfoeXlyy1f5WF+Ht669vEzHH2eQYiCxgkUr Iwhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=Zt1gUVX0IpCnPXwTyG8+humOtp/ZKrAnf7a59Q12nNU=; fh=0+oFXG7Ieo/IcxmdXcShUNq/5q7JRjuCkRn8APn3s9Q=; b=kETbIaQe25zMi9V4eULpcxk3yY3ULUybGWIK7jecxSP/GnlDyW51gI3KN2NiThoNzL 1muyZ6Co4iktzZZdCK/iCthLeovmsOcLtXtHimVOVtFkS+0u1b6Rf/5Zq84T7nw4DnT8 wzRPSZ2JqTR3/OrokK5KMFReuCtFmqY2JLcPleIceUJFhfXSz3yl7/ufW4LhrP57wjxJ sij3xh8ZeoymmPab0w4rc+WRQlBs9BzIyYyJ704MyY9tRCiL7ULTKzsIVujag0NeCutW isn8UShjWmUzsCcWmR1dI2B+9rgDSp9asnL8wL8tFDYKeOetQ2NksDSxHsl440lOuDVW dFZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fdj4QgCf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ms17-20020a17090b235100b00283a2f57965si7050989pjb.88.2023.11.20.16.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 16:57:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fdj4QgCf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 5B443802FAB4; Mon, 20 Nov 2023 16:57:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232758AbjKUA5J (ORCPT + 99 others); Mon, 20 Nov 2023 19:57:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjKUA5I (ORCPT ); Mon, 20 Nov 2023 19:57:08 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 938F2BC for ; Mon, 20 Nov 2023 16:57:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700528224; x=1732064224; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=nMU2J77ghZ+e8qdA0h9ywIv9K6Jb8YxZyIcZx9Q1D4U=; b=fdj4QgCfK4oCSPpNMVuBEIIMdXwKifhavNnaWpwAk9rOWbkKRBeRe4jw 53PSXllCUqy95DsewXPrMzYzPDxSDr+iZoVM0eMygiItA4w5eUtGkdI0O iV7zeaXkYbCv5OCIbGPEe1DR0eU2y+IadaqKeyoC4HjFqXjX9d8JB2Xd/ lbCbaE4GxULOBFg1zcLUKjGcJ+dhPQCtkl2B0FfKBLoz8zeRluxHoQnXE xBtJjSk49+AEpNURVLx1rN8H4FxNpf9+gYnDjFnmf0wNGolczzUnJD6Ij VV+TqBOKVjeN1cwgdnz6Wc6xObDxCFnhjJkgEDgT+ciNuAkGzNj/45nI0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="394580409" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="394580409" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 16:56:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="716376843" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="716376843" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 16:56:53 -0800 From: "Huang, Ying" To: Yosry Ahmed Cc: Chris Li , Zhongkun He , Andrew Morton , Johannes Weiner , Nhat Pham , Seth Jennings , Dan Streetman , Vitaly Wool , linux-mm , LKML Subject: Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios In-Reply-To: (Yosry Ahmed's message of "Mon, 20 Nov 2023 10:52:25 -0800") References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> <8734x1cdtr.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Tue, 21 Nov 2023 08:54:52 +0800 Message-ID: <87edgkapsz.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 16:57:17 -0800 (PST) Yosry Ahmed writes: > On Sun, Nov 19, 2023 at 7:20=E2=80=AFPM Huang, Ying wrote: >> >> Chris Li writes: >> >> > On Thu, Nov 16, 2023 at 12:19=E2=80=AFPM Yosry Ahmed wrote: >> >> >> >> Not bypassing the swap slot cache, just make the callbacks to >> >> invalidate the zswap entry, do memg uncharging, etc when the slot is >> >> no longer used and is entering the swap slot cache (i.e. when >> >> free_swap_slot() is called), instead of when draining the swap slot >> >> cache (i.e. when swap_range_free() is called). For all parts of MM >> >> outside of swap, the swap entry is freed when free_swap_slot() is >> >> called. We don't free it immediately because of caching, but this >> >> should be transparent to other parts of MM (e.g. zswap, memcg, etc). >> > >> > That will cancel the batching effect on the swap slot free, making the >> > common case for swapping faults take longer to complete, righ? >> > If I recall correctly, the uncharge is the expensive part of the swap >> > slot free operation. >> > I just want to figure out what we are trading off against. This is not >> > one side wins all situations. >> >> Per my understanding, we don't batch memcg uncharging in >> swap_entry_free() now. Although it's possible and may improve >> performance. > > Yes. It actually causes a long tail in swapin fault latency as Chris > discovered in our prod. I am wondering if doing the memcg uncharging > outside the slots cache will actually amortize the cost instead. > > Regardless of memcg charging, which is more complicated, I think we > should at least move the call to zswap_invalidate() before the slots > cache. I would prefer that we move everything non-swapfile specific > outside the slots cache layer (zswap_invalidate(), > arch_swap_invalidate_page(), clear_shadow_from_swap_cache(), > mem_cgroup_uncharge_swap(), ..). However, if some of those are > controversial, we can move some of them for now. That makes sense for me. > When draining free swap slots from the cache, swap_range_free() is > called with nr_entries =3D=3D 1 anyway, so I can't see how any batching is > going on. If anything it should help amortize the cost. In swapcache_free_entries(), the sis->lock will be held to free multiple swap slots via swap_info_get_cont() if possible. This can reduce sis->lock contention. -- Best Regards, Huang, Ying