Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp91529rdb; Thu, 16 Nov 2023 12:47:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvM23Wz/E4pOnmVk0x2hyHipGV6HPggQ/RRK/osFzpEx6NPo+wYOXo09a+El5pXSn/BvuV X-Received: by 2002:a05:6830:4103:b0:6b9:9288:613c with SMTP id w3-20020a056830410300b006b99288613cmr11370151ott.13.1700167633918; Thu, 16 Nov 2023 12:47:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700167633; cv=none; d=google.com; s=arc-20160816; b=Tnnpz64oibk5ntu2bg71aSTPAVVdk+9QZkUbSolOXXgXxfMJvvLRzajmPN7VGGt45U e2zxMPh+01E9niyM3jylHf7BNy2LNeD7WhtL2uv9VTxHEi0ldpw5MUxH8pj78ItpOp8d OY4lMiLDWYNyXtTuj5Dx8YneL+KV95SS2QSS9LjL/zNMgSTB6ulYwzE2LMUt4RD2FdHk HxZAnmqqUNEUPDPittzcweltQdbTwjzeMl7KYzBF5L5MsghAaEdionovyGzqI2Bdi8Ca zedJiHu6XP0+PTrYQAX+vEK82l2qePa4CtMmMkybVhxcNLhaf0K3dXg4XYY+/IkCw4Bd YjbQ== 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=9aSp9lzLdexzLy4YCwYMOeITU16swn1+BuYTl7JNpDU=; fh=+cmGLfBiyC8Xjdz0pZBT1RWrd6GCmGsVhFRdg7eud4o=; b=xQcRxGf+V+bicich0fRL7+k53j/SFFAGZuzWOhR0AsXiyHODkYJ672/GOVWgPsw4Wx +VVQ98rtZJH2MLF8Z0VTpoKDo2HrZoGJQr1b3MT+jFkc2dmbkKQtb6DIP0IF3lbpDAoe URSG0C64m33TozL8oShPWrHVZHCNoEIf9UjiJnfvUovr7plRsTJqUOWDAPortPq3ONhg UHuoGvD1sLJT7qmIfYZa112bw0q0k08Ufmdmo0zRmg4givlnGY1IO3g64L1mTBK3tlVe kJna5IgOLTh1DgksNLLF4WMQSzZgWIrdRlNf14iIK3zk+KzkYaQwzjBOUZfutiUduIHT jVFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=uhxglTcp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c7-20020a631c47000000b005c1b5aa3f16si225455pgm.777.2023.11.16.12.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 12:47:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=uhxglTcp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 65F7581B4ACC; Thu, 16 Nov 2023 12:47:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345527AbjKPUqW (ORCPT + 99 others); Thu, 16 Nov 2023 15:46:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjKPUqW (ORCPT ); Thu, 16 Nov 2023 15:46:22 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A15B698 for ; Thu, 16 Nov 2023 12:46:18 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9d2e7726d5bso170608366b.0 for ; Thu, 16 Nov 2023 12:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700167577; x=1700772377; 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=9aSp9lzLdexzLy4YCwYMOeITU16swn1+BuYTl7JNpDU=; b=uhxglTcpjQINBu1pmoz+E5p81aLTTN5jY55YHkzzFnLbB5pKo4U3YxZ5i9Ba/d8LLq wTdONo92F109OHxXnOQ38J9CCG2HQv/hThs6HrWQSN1TxXT6vrAU2STX/qWrh16/YVTF LR4ERxlhoxL5J8PwvavRwtwBkOX65E0RNgxPCOu3cxEv1lUspNKZvBzyhsY5f1D37jrs FAukbxveInsvYQjAwyS8WMes8JYQpx+Jporh1nS+/4pX4kKA9Vz2ZxkdDNpBd0kH1j7T +bNz+0yhbyN2cCAQRC4reh4TW3cPH2jSJlHuWEDnIZlvxRJTzzSoG0aw7XujoJZSrJLF 2o4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700167577; x=1700772377; 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=9aSp9lzLdexzLy4YCwYMOeITU16swn1+BuYTl7JNpDU=; b=AA2xR6OjT4oOrMiforV31ghF7jlP5GFbkf+WqAt2ic3T7kC4jDW4vDkCPZLAQfNVbf J8M0Mk4jZzbVTyX4wQA41ukpBGnrNgMwQL0/OvPKpRQAWrShdN0u9QeM7O85ifkQUsrl DyKa0wTZbXIgKVWNv/kkce+Md/xqanUFlKHcmWHwtQPW+2u1T7s104jM0PIk2bXisk2x D9VA7FJTWtQzGi9zVu6IC6SigfthlUqkEZC70RDaOtvohG4hAMbLQhSAK082CgpYrxIb Ue1sp3QT1tNBemqFMCndVVmH34fHspILPI9CIWmmoWkRTvXIJdRcBNGCst1H6RPhYGYi YdOw== X-Gm-Message-State: AOJu0YwBKL6SQqygOI1HP0xCbDECS+lcIr1b5244htInEC6lusYZnzXL 2fzrIvYZh7uL+IQbQCrng+EKcXAdfYGtoFFbinrAIw== X-Received: by 2002:a17:906:361a:b0:9dd:bd42:4ec2 with SMTP id q26-20020a170906361a00b009ddbd424ec2mr11685133ejb.10.1700167576851; Thu, 16 Nov 2023 12:46:16 -0800 (PST) MIME-Version: 1.0 References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 16 Nov 2023 12:45:38 -0800 Message-ID: Subject: Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios To: Chris Li Cc: Zhongkun He , Andrew Morton , Johannes Weiner , Nhat Pham , Seth Jennings , Dan Streetman , Vitaly Wool , linux-mm , LKML , Ying 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 16 Nov 2023 12:47:11 -0800 (PST) On Thu, Nov 16, 2023 at 12:30=E2=80=AFPM Chris Li wro= te: > > 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. Interesting. Maybe we can just move the zswap_invalidate() call to save memory early, and leave the memcg uncharge call to be batched? IIUC we already do some version of this internally at Google. > > > Chris