Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2302142rbb; Tue, 27 Feb 2024 18:39:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJhyCzM1Ly7/+bRKUBmHhHuBul/k8sB4VU90nd3/aNp+HJ2Ia97sC3eQLWI9O407tjqCY3YrcrmB8h3L2WUeemkG64p3aDkndIUW8ivw== X-Google-Smtp-Source: AGHT+IF7f4Xzz1Xw3DPyxopDeSbwWd0nHnwi1K2c7FvPzXSwnRJlB26N2xgbnkqU+XdeixqBUuBA X-Received: by 2002:a17:906:150b:b0:a3f:d742:f353 with SMTP id b11-20020a170906150b00b00a3fd742f353mr7925066ejd.57.1709087956013; Tue, 27 Feb 2024 18:39:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709087956; cv=pass; d=google.com; s=arc-20160816; b=Jq+vKT/8TdObb+KwgYTW/3C2rX4eQ81HXHNJaUpuMFuvuU9pPf8MdZJ+0pDRug2jGP 5rwCbU4P+Balk+p8QudOj9Hv4USDqAUa0he1iSlpq1SNcni/56sNUPRxNlE7chtRJv9S IuuD6MuwXwTgvgLxnNhw4VvLfbAwTa4gEzIJ6a0D6hGxEoYBkM8Wz8Gf+e7M4a4T2KBd YvpkpCxSDUfnSzK+W/IBVe2jBedM+vmd/7s6qq7OKGR32iblB+1U3KrTHTVNxiEMYzhP 7+qzZase4dDGNVGAppui3idLC1SthhfOY9Q129h5yDxol0uLafdMnruIoOvVPUljvB9e MYNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=W49AL2L4dBY0pya+pySiI7auyAe7hw/1CeIi/DrQqm0=; fh=XR6oPHiMIdwVxiZrTnB5Ou2N3D8Wkyadlez/OLB6RAs=; b=DSz+5yG+BHVHQ45PyT7jEuRx+/32g4md6QUSJRQ/XSlLRlRcrTq502pnoXZxCEgWPP 2f7uVYrqs/CqTtAUdb6bTgabJ+tpl5tJHJzs2+Jibu3tVfdXAKOr27+a1kcU0x1/e08t V+zvUOsXLZhn8lR2U7/74O7vLouNKt69zDpTVCai/r8NGW1/p9FMTqd90+XfXXzLZuVZ WbF2WV0iXecE+LkIPajfGhXeS3y78xJA+qN/JdgIEK5xSYgV54y8X2rSJtPB85+khHeF EVwDEwVZKRqPg0qJZMiHHcFbAaiUMV5Ig8PyfJ2OdfcsfSJf5aUHj55BWNRU89ddb4So hSYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=M6VRNueb; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-84423-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g18-20020a1709062db200b00a43f287a732si255808eji.346.2024.02.27.18.39.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:39:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84423-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=M6VRNueb; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-84423-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BEEA71F27D0F for ; Wed, 28 Feb 2024 02:39:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1E251DFDE; Wed, 28 Feb 2024 02:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="M6VRNueb" Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CB411DDD5 for ; Wed, 28 Feb 2024 02:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709087948; cv=none; b=cGsw44TBJqTPU+HuJx27ZHwBnD0uGryHP9N3Pr2KMVObUI4hE9zXrU4ZyQCsPxOZsff4httJfVr8IW0vvbHTewWnAzPinfh1Rz4mgxKVT0KdwWNQ9fcosmgVpOPfyRcw8Fxuw2Nq6zjcJLuLMHp8ngXtj/lCyXIL31nXn7AQrHk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709087948; c=relaxed/simple; bh=XkYcjE4jYmgMfBuKBCqdEkgX/I6J5sM+poB02RevkEk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=hYrXzmDXH9FkmDUfmcihxlduOTuGWrhhn4N8GGx5Gmtj8/CnsdpIIOPsDGKudAFynLjAxPYpuu8fCPd54X3HQXKm5F+56A8yRlM8EGRerKlcVvuqtkKvBGpkx0DIsfuhKOb/PTDgYLe6YZc6oqZ4drjaJetx645j7F4Eieu9hZs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=M6VRNueb; arc=none smtp.client-ip=95.215.58.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709087943; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=W49AL2L4dBY0pya+pySiI7auyAe7hw/1CeIi/DrQqm0=; b=M6VRNuebEnauruoB8iKCfMYtMdMOamdgBCSZW52IQ7GDKnLjDrzulxldCWlGdIx6BMpYP1 sszPdsCbEcCUPiYDKUc2gtN1+4T2eL0sGHZcEpT33sXI8cfF+gFgxjv8OiBFLsK/UXQK5M T60r2pamlUoSwEVstvjnw61ZrIVspjE= From: Chengming Zhou To: minchan@kernel.org, senozhatsky@chromium.org, akpm@linux-foundation.org Cc: hannes@cmpxchg.org, nphamcs@gmail.com, yosryahmed@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev Subject: [PATCH v2] mm/zsmalloc: don't need to reserve LSB in handle Date: Wed, 28 Feb 2024 02:38:54 +0000 Message-Id: <20240228023854.3511239-1-chengming.zhou@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT We will save allocated tag in the object header to indicate that it's allocated. handle |= OBJ_ALLOCATED_TAG; So the object header needs to reserve LSB for this tag bit. But the handle itself doesn't need to reserve LSB to save tag, since it's only used to find the position of object, by (pfn + obj_idx). So remove LSB reserve from handle, one more bit can be used as obj_idx. Signed-off-by: Chengming Zhou --- v2: - Improve the commit message to make it clearer, per Sergey. - Link to v1: https://lore.kernel.org/all/20240227030045.3443702-1-chengming.zhou@linux.dev/ --- mm/zsmalloc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 63ec385cd670..7d7cb3eaabe0 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -110,7 +110,7 @@ #define OBJ_TAG_BITS 1 #define OBJ_TAG_MASK OBJ_ALLOCATED_TAG -#define OBJ_INDEX_BITS (BITS_PER_LONG - _PFN_BITS - OBJ_TAG_BITS) +#define OBJ_INDEX_BITS (BITS_PER_LONG - _PFN_BITS) #define OBJ_INDEX_MASK ((_AC(1, UL) << OBJ_INDEX_BITS) - 1) #define HUGE_BITS 1 @@ -737,14 +737,12 @@ static struct page *get_next_page(struct page *page) static void obj_to_location(unsigned long obj, struct page **page, unsigned int *obj_idx) { - obj >>= OBJ_TAG_BITS; *page = pfn_to_page(obj >> OBJ_INDEX_BITS); *obj_idx = (obj & OBJ_INDEX_MASK); } static void obj_to_page(unsigned long obj, struct page **page) { - obj >>= OBJ_TAG_BITS; *page = pfn_to_page(obj >> OBJ_INDEX_BITS); } @@ -759,7 +757,6 @@ static unsigned long location_to_obj(struct page *page, unsigned int obj_idx) obj = page_to_pfn(page) << OBJ_INDEX_BITS; obj |= obj_idx & OBJ_INDEX_MASK; - obj <<= OBJ_TAG_BITS; return obj; } -- 2.40.1