From patchwork Mon Dec 16 15:04:38 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: 13909885 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 DBB1DE7717F for ; Mon, 16 Dec 2024 15:05:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DAE56B009D; Mon, 16 Dec 2024 10:05:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 662F46B009F; Mon, 16 Dec 2024 10:05:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DC186B00A0; Mon, 16 Dec 2024 10:05:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2AB5F6B009D for ; Mon, 16 Dec 2024 10:05:34 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DA7E6160E24 for ; Mon, 16 Dec 2024 15:05:33 +0000 (UTC) X-FDA: 82901145516.05.B81B774 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf03.hostedemail.com (Postfix) with ESMTP id E5F3420019 for ; Mon, 16 Dec 2024 15:05:17 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BqT6A0Rk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361503; a=rsa-sha256; cv=none; b=QG0nBYlHpf6cXJGr0LP1TonK3tfZQ2LwzpJfAEI5IBP3Hj7A9QdYC4JziD/mCHuGA+OYSv CRKr3avMAC1H8tYlPVvhzT6c7iPMeYWjLYxqjo/zFWYpsCr3W4APy4lH6rV/o4LCuVsEJD JllyujsItoE8jglKPu2O0BnuZJwBPg8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BqT6A0Rk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 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=1734361503; 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=TGYFKe0E/kNM1MKqESCZrh7ZCQ5AYAYwRFP0Y/nBgK4=; b=nas8Za4e+6w8iwAqn91kjm3Q4tT+3qo4Sj6msHSeJjmUIBV7vO+XR8vmeInc58C4RVoQ+L l4ThKgqZBl+F3XB8+hV9/XyxTnPWMrFgmALy+EHN5ku63YOB9sIDVDf0Q6Z640aYvW+PnF f81T0mMd8T2mIWUv3smNm8xQk5+dvNs= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-725abf74334so3612355b3a.3 for ; Mon, 16 Dec 2024 07:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361530; x=1734966330; 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=TGYFKe0E/kNM1MKqESCZrh7ZCQ5AYAYwRFP0Y/nBgK4=; b=BqT6A0Rk3g+7NkqXK1dBz9/c+AHV/Xw5hr6YnWCZ70+iIjJvKIG7HV9IXY5HCQucUh HiB8xrkOJuGMggucxDWl6heKi9rN2DuAAjBvTXGlCdIUhRJW/QVh3ZhgQ8vS44obevDy ilsqN2jw9hZL2LSFKh6/ToBWwTIGqdSUKY85MIMASOFKmS8fw1zYNnAdPv+urz/HiU6X obs+VueMZGDO3x41EmBB62X22oQaDA6fcVBoAtJl9Nl1R89qBO2kt7I0DcidtrroZkRQ v54wO6CsSR7/I6ZlDaFkWQgoinJ2DkJVedjF03nDt0mFc3hLTbjMzJRWXC6vaoK3rcQz w1Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361530; x=1734966330; 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=TGYFKe0E/kNM1MKqESCZrh7ZCQ5AYAYwRFP0Y/nBgK4=; b=mzpTJKcIF0/VPsJGkDKyb3vJ6pLeYsPxlU5EZWnepun1jkx03QvYRmtSCv5yb+5DKs ZiOEKbrsgRrc38Pbblkhu+vNtHWPf3zSHEMIRjJOQIB9uIvHAbZZE9eShEMpRzwv9UiA exSmiCxw1sbZfmjaA69BlTto21P8TgyGkOWLEWnXNB1ggvnXXFaTw4cyAUB+41qpL37/ BxpJuVd9ZKQ+e9p265sKEEWAD0KL5UxRAigqndAibZyHZuVQbAv/LN8LLkvlzaiQfRB+ sL1pWbLhp0p+Nc5qezNjK77T9fQWr3p/U39KacRHZXUU88r2snKhBsgD74V0sYa5BZp0 yHMw== X-Forwarded-Encrypted: i=1; AJvYcCVMAHeWwFA/zJjZL5ZIzPllz9AJaWeSIYjSALEwd6hmUPuZLiTrjR9PkYA5IS8X8iTwQlVk28BKng==@kvack.org X-Gm-Message-State: AOJu0YyqPdRSIJN/kNDKeBNnCN67iDVTgZaP7Ias6/E+cpuZhjZjv7uX auvbut8ybd2DisPPc+rvjdWk4P8svJ7NScnFzkipnZEV6hMimiuc X-Gm-Gg: ASbGncuhREE8HeHOiH4qrYgvOW/55s44kx7pngTMkOgwdZPZ2rtNIBMwczyJQrXF9E3 YB98xAvPzkqf0smzZHymEekFeEfQs0xlqqONTq8yvNTbH/V/2eJwVaZdXIw0k26bgiCIaZRlq9u Yvr9s9RjpvPTYwQKzvgho4iPsjP2ETPXTFuNqTu04haHrSQll9AKYIM8yp7b7qq/I+IJdNnuHbj unMzGUeI2rHWNWyUWRsE7CRHCzTs/tHmDZzPWtaS8rX/IBMHFy5RPYAC4YZ++wT+EI= X-Google-Smtp-Source: AGHT+IFpIb/eGN3yySKeKTyiWJ616xagwbMlJZ9wXbZtp5yUACdJWvrAdhrDWPBUBkRbz2h9x6UY4w== X-Received: by 2002:a05:6a00:cc4:b0:726:41e:b314 with SMTP id d2e1a72fcca58-7290c24324cmr18035403b3a.19.1734361529832; Mon, 16 Dec 2024 07:05:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:29 -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 07/18] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Tue, 17 Dec 2024 00:04:38 +0900 Message-ID: <20241216150450.1228021-8-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-Stat-Signature: eh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xR7rAMNC kLoOTN5+ 3OGVikUdxBfaGG6W5oDHnlsEi8l4muW4lHCMTYdkAFtyzUB/xwi8AxonJ/dRf4cfpoM17NPRxRNQL1o/nzrF9jxIfb7rEQWmKQq3nVGmEm2IHPA7oTPkXTpE8v3Lu4L0HXQa1GAkcuYXDrieRS0xTEE6lH4EJVroH3iW5uzyrdUdxaA/segy86IJhOuz4losSw71cujPOlyDiejfcBhnPxNNE+fkV5vEVGtfag3kb6pZebBnJ64eB+Bg20wyMk1Mafqx96ngx4MhFUNlsNl9l0+u7f1UT3EcDnv6e1UIsg2RDGj3SNAFmVTyjyqXo/BWNn2/zv2ITbhhGVKun/Up7ihSI9GhpSIGnKpJYqd/DeiiPqV8VfZVKCuWu61nzSWOIFFaqr9L5rzxXM/vwRIyC7kr6rPL7lQIypurGvOVRq6FPHu8Yfno0jF1vFfOkovxwVmzFNgoluU4LOBiuEGB/gdqEayL3OKV2cPOX9u3JhBLXUwF3ShVyaouFmBIDsC/J2R6HzYkQ9awLEKmrLoN0BfM+8k29stPfkXiMM55lM638Prg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.280769, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert obj_allocated(), and related helpers to take zpdesc. Also make its callers to cast (struct page *) to (struct zpdesc *) when calling them. The users will be converted gradually as there are many. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 59a30c61160f..a3e2e596b4f3 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -823,15 +823,15 @@ static unsigned long handle_to_obj(unsigned long handle) return *(unsigned long *)handle; } -static inline bool obj_allocated(struct page *page, void *obj, +static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); if (unlikely(ZsHugePage(zspage))) { - VM_BUG_ON_PAGE(!is_first_page(page), page); - handle = page->index; + VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc)); + handle = zpdesc->handle; } else handle = *(unsigned long *)obj; @@ -1569,18 +1569,18 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, * return handle. */ static unsigned long find_alloced_obj(struct size_class *class, - struct page *page, int *obj_idx) + struct zpdesc *zpdesc, int *obj_idx) { unsigned int offset; int index = *obj_idx; unsigned long handle = 0; - void *addr = kmap_local_page(page); + void *addr = kmap_local_zpdesc(zpdesc); - offset = get_first_obj_offset(page); + offset = get_first_obj_offset(zpdesc_page(zpdesc)); offset += class->size * index; while (offset < PAGE_SIZE) { - if (obj_allocated(page, addr + offset, &handle)) + if (obj_allocated(zpdesc, addr + offset, &handle)) break; offset += class->size; @@ -1604,7 +1604,7 @@ static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage, struct size_class *class = pool->size_class[src_zspage->class]; while (1) { - handle = find_alloced_obj(class, s_page, &obj_idx); + handle = find_alloced_obj(class, page_zpdesc(s_page), &obj_idx); if (!handle) { s_page = get_next_page(s_page); if (!s_page) @@ -1837,7 +1837,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page, addr, &handle)) { + if (obj_allocated(page_zpdesc(page), addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx);