Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp916967rdh; Fri, 24 Nov 2023 00:39:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGerhvvWKau7pDwhcckpNszrQgnEe0N+eqXzR7mAT2T0kbaXKVlj+GLjOXq0xq+SRQ21qm X-Received: by 2002:a17:90b:4c48:b0:279:2dac:80b3 with SMTP id np8-20020a17090b4c4800b002792dac80b3mr1909011pjb.44.1700815141538; Fri, 24 Nov 2023 00:39:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700815141; cv=none; d=google.com; s=arc-20160816; b=T+PJdXhwbcDEMcMXhOzwWra/+m6bkCoN1Rb4+0PqbfGkNQNrPt670WVuBOzQKCT5Nf sthFNJpqQKMOt7avEEjVyaEoEY9Gj3/yv7CEIJQsxhkvsUp4U/D2OdYoGB2Bj2TRSyIi kz85WzltMxnP3dLUhlFhreClOqYptpbnTz2VmBb13YKq81pJYeL+S6PvHkUK6bYsdFtW +nzjwP8nKJpmLEUsMuhTr+YOk9XJrsWNVuefPCHSuXdvpKrXyl8Tt9uCC5ysX8ARfIWn m0WHWSjoLhAFezjNCeaFd2/xaibRnITHNDCsgVOy29WoWLiqC0zDL0j3wLDVWgCP1VhW 74jA== 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; bh=XcITGmWYxILzjGNVLxOyiDE5P+utESonWD069VvulUs=; fh=K/LZ1BUptwrDpCNjVhfmA07Y8doOUYOQskSkVF/w5AI=; b=jXnsG9x4VTkI69qPFsEppwIVdUvNJAzV1lzhnaGzZmRTYbNVLgtjL/Pn+AZjwOT9sV Fm0vzA+c+0cU3YIScJ7BiJLztGwGndQ0Qa8BAMCIFVbMKrw81xFaGPdlUpJEMPiEaUF0 NlvJaYmPMPyvI7ghL0XZs4HRrDJnXSrtKcjyzg8MK0vneZ/K/c4dO9dlslMoOnYAJ3xv Oe0KPmI1E3VI+qLd7n7FXucbJiQJUuXRHvDdMKTwKZZTnXtRqrqnfFhH63Be3Y+qTv7U cvAiEEG6REZJHGCed7vd+qkKOVITiwBThAVVeJuEwYdtlOFZJBxoejhV1RHmfNT/fYYm woIA== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id iq17-20020a17090afb5100b0028589f571fbsi1121064pjb.148.2023.11.24.00.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 00:39:01 -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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6A6AE81E3E28; Fri, 24 Nov 2023 00:37:33 -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 S229742AbjKXIhT convert rfc822-to-8bit (ORCPT + 99 others); Fri, 24 Nov 2023 03:37:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjKXIhR (ORCPT ); Fri, 24 Nov 2023 03:37:17 -0500 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F201D48 for ; Fri, 24 Nov 2023 00:37:24 -0800 (PST) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2c6b30aca06so20431861fa.3 for ; Fri, 24 Nov 2023 00:37:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700815042; x=1701419842; 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=eCm2VbiM4tYPYLjATXAxUR88qLBixqCgfFCYij5grcs=; b=BrB3wlsApjQg3lCh8PsOKGOFDbOF5JQCBWuxCOmDchDq072u0vz5iwP1lAw2roSOar Z79Vf7MsInaTNjUOSF9h3lp9p30O/pLccEhYaACB1ojoGrn76Og0ZUgCzb2VeDW7X7mQ 23LFrGQuI2jWAQkZO3pEHGqJEhXzyYW4/qFycJJ5UAGOpvaecJMpiJQUgYgrEQrcbMVD k0eqzowkyTdZz6gHOK49W83HIFDpFd8z9f+jrbkyOwH3NPFut/cxSqRoRgOgsKEqIBs6 gPhSjUTAyo2xQjpQ4pzO1A9f7TjYmcsJx7L1JpPi3LkrjLLTtuC5lJeHv//KHZgSs7V7 MdrQ== X-Gm-Message-State: AOJu0YyYrqiGDN53bXBbjTDSZyP+FwxuqvjiA3YMQ8oQ521la0Rpe3mk Ot4kjaACeybZAQEjBY6qoi3a97McO9FfRzbgdA== X-Received: by 2002:a05:6512:3484:b0:509:7141:fec with SMTP id v4-20020a056512348400b0050971410fecmr1182027lfr.48.1700815042245; Fri, 24 Nov 2023 00:37:22 -0800 (PST) MIME-Version: 1.0 References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-5-ryncsn@gmail.com> In-Reply-To: From: Christopher Li Date: Fri, 24 Nov 2023 00:37:10 -0800 Message-ID: Subject: Re: [PATCH 04/24] mm/swap: avoid setting page lock bit and doing extra unlock check To: Kairui Song Cc: 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: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=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 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]); Fri, 24 Nov 2023 00:37:33 -0800 (PST) On Fri, Nov 24, 2023 at 12:15 AM Kairui Song wrote: > > > folio_put will discharge a page if it's charged, in original code the > 2 folio_put call simply free the page since it's not charged. But in > this patch, folio_put will cancel previous > mem_cgroup_swapin_charge_folio call, so actually the 3 > mem_cgroup_swapin_charge_folio calls will only charge once. (2 calls > was cancelled by folio_put). You are saying the original code case folio_put() will be free without uncharge. But with your patch folio_put() will free and cancel mem_cgroup_swapin_charge_folio() charge. That is because the folio->memcg_data was not set in the first case and folio->memcg_data was set in the second case? > > I think this is making it confusing indeed and causing more trouble in > error path (the uncharge could be more expensive than unlock check), > will rework this part. Agree. Thanks. Chris