From patchwork Mon Dec 16 15:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13909890 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23831E7717F for ; Mon, 16 Dec 2024 15:05:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 728486B0085; Mon, 16 Dec 2024 10:05:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 663C36B00A5; Mon, 16 Dec 2024 10:05:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B4C36B00A6; Mon, 16 Dec 2024 10:05:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 193166B0085 for ; Mon, 16 Dec 2024 10:05:49 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6AB4916105A for ; Mon, 16 Dec 2024 15:05:48 +0000 (UTC) X-FDA: 82901145600.06.EC59912 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf02.hostedemail.com (Postfix) with ESMTP id 6326780023 for ; Mon, 16 Dec 2024 15:04:50 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=J9787JXf; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361526; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Okd8af+xJ/uPeTS2068jlInbQIVkoFnfMsYSI8mfzHU=; b=MZq0qQVbNzhBzkwAjP6fJqIJ0yCz8DStzjFQevRaCDECRQ+I1D7kezg4NkKjV+o0CGFXXT hcEKpOmyfzfH83jUPU5F/KTvFslHZKi/rZD8aRO0WXTkk72ku6Dqado7bkJsKgoclmXwSK 8pgZtSN2LuCwFmPSIObGly3WxmZO9IU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=J9787JXf; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361526; a=rsa-sha256; cv=none; b=a4JwtittXXYu5baVBS/KvNSSx/sgos5t+AkVBHEDwRoxXBPvpUMCViBn4PhMYBabbnbhgM gGSz00rGI2/DFwNrQszvvoPZr3ODvKpp6j3Fx/HXQgHSrX8cV9QPuTzCwaK4ABppHH+dNX m7fFMAWw66wNqNw/iuPCIqjyovZQTx4= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-725d9f57d90so3046208b3a.1 for ; Mon, 16 Dec 2024 07:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361545; x=1734966345; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Okd8af+xJ/uPeTS2068jlInbQIVkoFnfMsYSI8mfzHU=; b=J9787JXftwEyeg4Bk4TqytZOdS1ucszhv4qFeLLhmm+vAKcndBrRerAveR8kGbBF+9 cklQU8bhyluHA/O2u6dGojExlbL8yQAMIJLVdV+wHLCt0+f6Jjirbpe3vAR7SEi0ph60 ElJB/I2P6RVYhXX6kBhm73zJ/LxfJhAIhOVO7hGIeEV3taTNAmFtgoe0jBZ8LbrRebQm NxnVsePBqbWbORNBn7F1wCqmNTCBg+9TXwoJsROC0H9L++6yMwyFxZ4luNv39vye5ndA RQIkzKedCy1DEr0QHRhF+P8aWxwIfznfI2rirtEF3bWv8/EMAR2UpdbQI94vKGHTzr1Y 6Vzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361545; x=1734966345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Okd8af+xJ/uPeTS2068jlInbQIVkoFnfMsYSI8mfzHU=; b=MVOzmLVSR7/lgcq/9mlufbB1Asp1nYSPygAyy/9NbpCN/I2kl/Z563QeUZJDJFidp3 cXp9Hp7OXmgtmejTup4wS1QjA8NcbELcnDcrrClw4zJ/9HpGvENKt5ZQ0PHZQce25Pxs tOvr3ZTIels9w+8gl7w1et+VKnXXncyFm4lYLKGEH2DDxBmwWsIYsk7PyCo4AH20UPpp bEc4jClXlCltJjW+hgWAnEnJFPeoINDnARNstMAB0t976rB2Th0q/ieJ4ZFtm9mST4fV IqEXCOLIQD8q83aEiVU3nEUawJjRRYqPeMq3J3Qr3qi8CvkMyD+9Eg57lLz7fGVMUlZr qiPg== X-Forwarded-Encrypted: i=1; AJvYcCWM2D9ALPCILSF5mWxqsEHYYUk7HYTLhSN2CFiJN4FgbehQ+2p+aA82CJ0GVo2UM1CMZB2RilkTTw==@kvack.org X-Gm-Message-State: AOJu0YxyAqXYk5D40s+kTaaoVfJ3bwq/iWrSCAA1OyIX0LaM2Bpv3jI9 O2wMEUuMPim7C7ISs8W9hJ5OAYFdlv2zKMI2OI35DmaDTd2llP8g X-Gm-Gg: ASbGncvq7epL/ON1BwfSEnQP94YetNblenEk1+75U+FCqEvmSt2+UrQ25zkOdVBsw+2 WMfgjODT0xXsG6+/fMe8JoEq6AX7W/ricl/i1KKjnReynmnsih4nS5yjjE+/04JBeho3CC/4tO9 QWE7ww6uwFBnLHGG/U1kCWi2k+CWemcycr61Iw/WbjlzLG6R9Q4Qox4luXu6HQOSLlCt8SgH63h 3FwndakBkFAI4dQQ4lDDl0NhGJUHB9pS+XNKaiQdkrc5A+nagPEvQ+3+tjNzg+P/9E= X-Google-Smtp-Source: AGHT+IFGnR9oXP/IG3Lkz00eu1Mfb0rQPKxhmwE/05PE6I6j7UQQncxs1M5cSGZ1liehbE42sniAYw== X-Received: by 2002:a05:6a00:4c90:b0:725:dab9:f734 with SMTP id d2e1a72fcca58-7290c12ed78mr19087392b3a.6.1734361545300; Mon, 16 Dec 2024 07:05:45 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:44 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 12/18] mm/zsmalloc: convert __free_zspage() to use zpdesc Date: Tue, 17 Dec 2024 00:04:43 +0900 Message-ID: <20241216150450.1228021-13-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: 4q16rgi5czshuj9ywxw8b46bg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aRG9fL72AkUt7yR15XO3p/aigwwkc7i85wKPe8t8s4f34f51R/IkcBV1FQIp14NA51AUdefHv/wDgdK+iOrchXSdMzBen+W9DaTvIlU4KPTWgslo7uuguUEe5zoqlvDVUH9QlCppDuiiXXYvFqIZo++DrNft8FFn1IHPReuPIELZN8GrY3IzCVZvaRtmY/asasBk1swSsmhtUEfcAO4lWuu4/O4nH9MjP35r+amIDm0qKb5KHCFZYb/STACxK8KRHexp4++Dha4gZpG8MQc6/THqVPdDqBJVFnWI/M17PqXEHRQcXkx3tLQ2MFW0z/1CNWicP6e6Dk/W/WHX83Oi9eGsg8dHNtEtpT/ewfntXWWd2tpvNubpu2laC2le8LEKxypQmakRmDkr/8Ul3OU1gAAJFurdrerOMjDgZHIlsQVeGyiR7Gzx1CX5QwTCGSgmXMbVeUpdHrTN5VU2x7fh1gbdWehECT3ZR1gNAeqUB4zUsWUcgD+iTpccAPvPxVAOmFTxhUrkrpZgHVSFBWsKq6yzqxTa9C2vprG3Cy2ieHrL4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.429860, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Introduce zpdesc_is_locked() and convert __free_zspage() to use zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 4 ++++ mm/zsmalloc.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index c7c52e05e737..fa80c50993c6 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -165,4 +165,8 @@ static inline struct zone *zpdesc_zone(struct zpdesc *zpdesc) return page_zone(zpdesc_page(zpdesc)); } +static inline bool zpdesc_is_locked(struct zpdesc *zpdesc) +{ + return folio_test_locked(zpdesc_folio(zpdesc)); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index dded6d1f3b7a..e1f501d51226 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -878,23 +878,23 @@ static int trylock_zspage(struct zspage *zspage) static void __free_zspage(struct zs_pool *pool, struct size_class *class, struct zspage *zspage) { - struct page *page, *next; + struct zpdesc *zpdesc, *next; assert_spin_locked(&class->lock); VM_BUG_ON(get_zspage_inuse(zspage)); VM_BUG_ON(zspage->fullness != ZS_INUSE_RATIO_0); - next = page = get_first_page(zspage); + next = zpdesc = get_first_zpdesc(zspage); do { - VM_BUG_ON_PAGE(!PageLocked(page), page); - next = get_next_page(page); - reset_zpdesc(page_zpdesc(page)); - unlock_page(page); - dec_zone_page_state(page, NR_ZSPAGES); - put_page(page); - page = next; - } while (page != NULL); + VM_BUG_ON_PAGE(!zpdesc_is_locked(zpdesc), zpdesc_page(zpdesc)); + next = get_next_zpdesc(zpdesc); + reset_zpdesc(zpdesc); + zpdesc_unlock(zpdesc); + zpdesc_dec_zone_page_state(zpdesc); + zpdesc_put(zpdesc); + zpdesc = next; + } while (zpdesc != NULL); cache_free_zspage(pool, zspage);