From patchwork Thu Jul 13 04:20:30 2023 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: 13311279 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 22D09EB64DD for ; Thu, 13 Jul 2023 04:21:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B21448E000A; Thu, 13 Jul 2023 00:21:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAA078E0001; Thu, 13 Jul 2023 00:21:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94A298E000A; Thu, 13 Jul 2023 00:21:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7B8308E0001 for ; Thu, 13 Jul 2023 00:21:40 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 52E5716010B for ; Thu, 13 Jul 2023 04:21:40 +0000 (UTC) X-FDA: 81005289960.05.C752251 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf09.hostedemail.com (Postfix) with ESMTP id 79A6114000F for ; Thu, 13 Jul 2023 04:21:38 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=gDl0JF5e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689222098; 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=uEDSSIP+zt5V9XvZT+ict1746NWdOpkIhk/ClYlbKG8=; b=TzDx4ijVKPMjDnm4JZ701iVvIJrz8Fr8oauNKFNfUBW4WBQIeLomwwp7+OZaoGCRsc8jaw kHUb+49CG4OUafuAVptk6T7UASmwqK75WXxQHQ2UuljSAxCEtwHPcyL3qUTSjSGgXbwlJE YkniQwXYooR9H5KiLrvQiU1bsCTimUI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=gDl0JF5e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222098; a=rsa-sha256; cv=none; b=Gy6wjlSLzoPX9ArMT2RcgG9mw1qpYPSxnp10QVMClzPLq096v6SAvfjAAd8dXI4BhNkHe3 8aiITKthEbB5+Wgnxr2WaPq6pz80sMPugiYotZPO3Gxz2xUGpfpqgwLGicqdEA6E2wMgFI IOjRL2hLSXNu0/7+0pdyoRES8NgOBXk= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-668711086f4so152261b3a.1 for ; Wed, 12 Jul 2023 21:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222097; x=1691814097; 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=uEDSSIP+zt5V9XvZT+ict1746NWdOpkIhk/ClYlbKG8=; b=gDl0JF5e9zGpLRmEVQgEpzZ1YDB6JYSyOV9cQpeI18V9wzgjkAQF1WTsMsyU3VSoLf 2e1cTn7O+bGR8vWOg52VMo87dUBAfJiYwc2XktidpZUMY8OfM7ngVE95TQkHX66SanQW dgpC/2e8PppNekV6zRbcREFOHsjqAgeaozdTGFKKnnpBYoeg5Fx0fhAYs2W/ui/9MoZh 69aAO90DqMUuP75JGEeTXuZFg0xeVjbCPiw5v3qygq7ShgW2gTRi1GIszh84o4kPH8Qj 0sUZz+95DRgGUeST8VzIXP7PSo/0vTH8boyycYF9NPSM14W03PRBlwUQO6t6BMR04X3p PekQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222097; x=1691814097; 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=uEDSSIP+zt5V9XvZT+ict1746NWdOpkIhk/ClYlbKG8=; b=FPPV7srKefL+FysxJ432LRHYPq9baQMyPF5835Y7sU8LxXaCLR3slmzD8uH6p5jlVA C5LmoaT20nLyZUWfBB/q7Ktxcl/bVa15/EDhIWBnkXEHFCQ3PlVq0H/195H5UmyNgoB0 93ox0kAy0Sctu9RUij3XHDWyDM/7ineIlGBnzr4svfmbGzDCvzNhXnshg4lhngdvfb2a iiYB2p9Xu1VriiE0y8KrVIqzRlrUFw1divO3qpdXkcXRze0/1Pa+pxDHrjfZcET8n8GM 3ephLvIdKmuxiJIHW1CobQyNkKWPFqqDA/Shed5JfRWffD++ZokwTQzLqMnOjZ4FfiVJ jSIg== X-Gm-Message-State: ABy/qLabbChOhtcnSg5bjnBzpKMx43nb0Jvbb7PWYlhTp0AMtCZtVXTm TreBbWdws7qWR3gfGMRu/Xk= X-Google-Smtp-Source: APBJJlFlwg2pA2K3WdR4ybI758//TlSODxXQDA/TxlawtEXWCY8PW6IRxuTtLqAcqkjZbNPwiFTClw== X-Received: by 2002:a05:6a00:1a8d:b0:681:919f:bf69 with SMTP id e13-20020a056a001a8d00b00681919fbf69mr1060619pfv.0.1689222097302; Wed, 12 Jul 2023 21:21:37 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:36 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox , Mike Rapoport , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v2 15/21] mm/zsmalloc: convert __free_zspage() to use zsdesc Date: Thu, 13 Jul 2023 13:20:30 +0900 Message-ID: <20230713042037.980211-16-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230713042037.980211-1-42.hyeyoo@gmail.com> References: <20230713042037.980211-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 79A6114000F X-Stat-Signature: m39t9xugztqaoea87p5jqn9yafc64ct7 X-Rspam-User: X-HE-Tag: 1689222098-161236 X-HE-Meta: U2FsdGVkX19fe0UEUpi9HuEQiMp+uA3xYZYWX1RRCkRZN3bwJiiol5ERRT0lYK4zrzr9gMkJixa7b7LDgRuOcM3kWxTUSy4xedhEsCDDMoytWy5CLdqCcwFYVVw4B9YetsWYoEYbajOxjkmSYIGdzaXDpCLT9XcAIX3ctsvgRlFhI3kB6SZycSknbMCl4R24qNGgYG9SQZLdb/0w2jRGOvvDggxXr5RXQVlVrHhCbt7aroWkXUwsu7BiST+j52wpfhM9cVch6/RCD2xM/D5HzBiJFsqwJdoyLkJhUeLdUz9Flcf1jvC2xugWRFaJlxP5kj9ILGxlHydsRwhtgAZ5x5chisXa2zNRykTCPBKpTPxsMAAy0DNGcDVl6Tgz/7n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pQ1QKF589VTpAdSDQW8O39lJ2cMhP4e+TtrnBZaxgEp8dfF35aFk9Tav+/py0C/hkKqwGcj9eUrzbt3JsxE/0cLS6NeRt0llGGbMiMCD/LgOEuFIamTgxAxVzNQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Introduce zsdesc_is_locked() and convert __free_zspage() to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 9e4ced14e1eb..69bd497de35e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -336,6 +336,11 @@ static inline void unlock_zsdesc(struct zsdesc *zsdesc) unlock_page(zsdesc_page(zsdesc)); } +static inline bool zsdesc_is_locked(struct zsdesc *zsdesc) +{ + return PageLocked(zsdesc_page(zsdesc)); +} + static inline void wait_on_zsdesc_locked(struct zsdesc *zsdesc) { wait_on_page_locked(zsdesc_page(zsdesc)); @@ -1007,7 +1012,7 @@ 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 zsdesc *zsdesc, *next; int fg; unsigned int class_idx; @@ -1018,16 +1023,16 @@ static void __free_zspage(struct zs_pool *pool, struct size_class *class, VM_BUG_ON(get_zspage_inuse(zspage)); VM_BUG_ON(fg != ZS_INUSE_RATIO_0); - next = page = get_first_page(zspage); + next = zsdesc = get_first_zsdesc(zspage); do { - VM_BUG_ON_PAGE(!PageLocked(page), page); - next = get_next_page(page); - reset_zsdesc(page_zsdesc(page)); - unlock_page(page); - dec_zone_page_state(page, NR_ZSPAGES); - put_page(page); - page = next; - } while (page != NULL); + VM_BUG_ON_PAGE(!zsdesc_is_locked(zsdesc), zsdesc_page(zsdesc)); + next = get_next_zsdesc(zsdesc); + reset_zsdesc(zsdesc); + unlock_zsdesc(zsdesc); + zsdesc_dec_zone_page_state(zsdesc); + zsdesc_put(zsdesc); + zsdesc = next; + } while (zsdesc != NULL); cache_free_zspage(pool, zspage);