From patchwork Tue Feb 20 11:44:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 203569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp339567dyc; Tue, 20 Feb 2024 03:45:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXhSZtCZ3kcaDzUppmIta6gDjZxYpxLvC/9zXbhc7jzizxrbEksgHp4AeZPP7zkSk3jXMI0o9kDeZW78XN0aeCAXZRKTw== X-Google-Smtp-Source: AGHT+IEoPViNkWUZg/HrUCM/P5kcySpUMM+TVG+h9fSqjrKQBrTHFrkArmh/auXzNQFzBG4h/llt X-Received: by 2002:a17:903:2a85:b0:1db:c90f:e189 with SMTP id lv5-20020a1709032a8500b001dbc90fe189mr10294060plb.57.1708429527312; Tue, 20 Feb 2024 03:45:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708429527; cv=pass; d=google.com; s=arc-20160816; b=G2w5lO2IhtXdDbwGYytFno/ORF9jV20Cn4PdctwwAVY5uWF5Sqkwj6FY6BBOl+06lo XzJndrlSIW7alpBUX21YZo7lZhdVE/Y/L7THUaUNgM7rB9SNqyMfX7JmNm0dGXOZV2Ul EXPQu82L35FF/xVtljRZXBIW6UFxW4Xc6ELKzMwY4cR48zsAhZSpUmN1GanwtUaKNrH8 NRMfOldFwTrEIA38HYQS7btiCBVM4wAtnZO/BK8F5MlC55wglXIJARX5VQZZ72+Bgahu fqVzmsOsbZdH3mfAu68ugXUu4wNlNgbCxD6qxr3ThWS65RGH/5cuu63uMF482IRwxHPS nJUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=VdP64AtdS178q4SDQJio0KmQ+nTJNdPzbvzklfYy4hs=; fh=CIhmbM3N522iZfKAx68dio1DUnYohA/38dvKjB2Sibw=; b=pdwn6Qh1LBQvhJ8uxXnBrssR+t1Fh+NS7hCRzk6r6MK6GrMAQpP24jYdKu00QliLzt YYZdkrA6FnHhbmOohZChvNZ9Yea8e3vwKBn+5W3yAhGP7q/TzqX1eaVS/gSLyC44gBgq C1i0mJ/B9FAsHkPJr1q53KNkrsbtkiUHTA2n8kXpk3Fv8F6n8nFkE2S53fe1Zff/CnLk sdaBUVyT5iKLfnEJMe4ELTp6q5RI3RQtodWTbn64bmmc8Dk0gdJJViNaktHzRr9U+EWY f8R+uTVm90xPzJUjfdu2pqP1pC6eemt0RF8HfQgYDnP5TtWjsgJatyEuqnv2IsZzSISu qwOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cwrTmA0s; 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-72930-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72930-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n17-20020a170902e55100b001db7d2a8cb5si6239405plf.437.2024.02.20.03.45.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 03:45:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72930-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cwrTmA0s; 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-72930-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72930-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AF8B82867C9 for ; Tue, 20 Feb 2024 11:45:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8092E67C5A; Tue, 20 Feb 2024 11:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="cwrTmA0s" Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (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 4757666B2D for ; Tue, 20 Feb 2024 11:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708429484; cv=none; b=ocCK3g2olok1pkz+qX9dSsQ2RSoqaTO+t8urZ8AJ5giV0L/tE+aBpA6E09RLSk8NBTvOScsobOPDFnyZ05p0oeO+QKqAHO9MI7b5KNUNv9afQMeLtsHEx/X1xL31SezTm2wk4wgjuBt9Q/CXA0qh9KftA2z8r062yF5mrKyxmfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708429484; c=relaxed/simple; bh=kdgQ+vIp+GUEXt8gpLV2Nl0qbyy7LFlK6JMx7o2Phgw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pq0uNpqgemdJGgJ+8HHRIIb1inbUYMy6sZtUH3/2yUZ/PgW+Cx4bchEeBQ1OpNoAJ8vQceJQlpbppTav1LFDY3Y3sepxCva1OU6SGLPXzMC64uWFFdFYcr5VeRMTxCtRqQt4+GEMHEA9my7O67yY9ODqpawVGWOwEpOoTH0kngY= 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=cwrTmA0s; arc=none smtp.client-ip=95.215.58.179 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=1708429480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VdP64AtdS178q4SDQJio0KmQ+nTJNdPzbvzklfYy4hs=; b=cwrTmA0sPvnMUtwA1woeElKaxcGZpRmNkxQyoQlraw0/zO68U4jf0+tF/GGDIFjo092brD MbMMc1y0eiy8oqd6A3oW0hX1mpmoCKUB5Ic238upKw/66Sq9v557RCnf7Zuci8Fb/6+ktp Mi3mbziPE2AVdaVY3GIzj8PWB9dDJpQ= From: Chengming Zhou Date: Tue, 20 Feb 2024 11:44:29 +0000 Subject: [PATCH RESEND 1/3] mm/zsmalloc: remove set_zspage_mapping() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240220-b4-zsmalloc-cleanup-v1-1-b7e9cbab9541@linux.dev> References: <20240220-b4-zsmalloc-cleanup-v1-0-b7e9cbab9541@linux.dev> In-Reply-To: <20240220-b4-zsmalloc-cleanup-v1-0-b7e9cbab9541@linux.dev> To: hannes@cmpxchg.org, Andrew Morton , Sergey Senozhatsky , nphamcs@gmail.com, yosryahmed@google.com, Minchan Kim Cc: linux-mm@kvack.org, Chengming Zhou , linux-kernel@vger.kernel.org X-Developer-Signature: v=1; a=ed25519-sha256; t=1708429476; l=2317; i=chengming.zhou@linux.dev; s=20240220; h=from:subject:message-id; bh=cqkPrPVAWUs+Ao8dP81X35doam5/5XwHmrqtbfkzja8=; b=fJGX+bZSZ9DmHcZLQStOZiyYVufKsK8+b2cCFX9z5c6zB+JgATrPXCCxaEuuk1J57ChPoEPcs Y8dHZRV9xLBDyR4EYl5pMCg/yarVPtVH/ac7GQz0+x5knNUdq0ZOH7g X-Developer-Key: i=chengming.zhou@linux.dev; a=ed25519; pk=5+68Wfci+T30FoQos5RH+hfToF6SlC+S9LMPSPBFWuw= X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791418200236364251 X-GMAIL-MSGID: 1791418200236364251 From: Chengming Zhou We only need to update zspage->fullness when insert_zspage(), since zspage->class is never changed after allocated. Signed-off-by: Chengming Zhou Reviewed-by: Sergey Senozhatsky --- mm/zsmalloc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index a48f4651d143..a6653915bf17 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -486,14 +486,6 @@ static struct size_class *zspage_class(struct zs_pool *pool, return pool->size_class[zspage->class]; } -static void set_zspage_mapping(struct zspage *zspage, - unsigned int class_idx, - int fullness) -{ - zspage->class = class_idx; - zspage->fullness = fullness; -} - /* * zsmalloc divides the pool into various size classes where each * class maintains a list of zspages where each zspage is divided @@ -688,6 +680,7 @@ static void insert_zspage(struct size_class *class, { class_stat_inc(class, fullness, 1); list_add(&zspage->list, &class->fullness_list[fullness]); + zspage->fullness = fullness; } /* @@ -725,7 +718,6 @@ static int fix_fullness_group(struct size_class *class, struct zspage *zspage) remove_zspage(class, zspage, currfg); insert_zspage(class, zspage, newfg); - set_zspage_mapping(zspage, class_idx, newfg); out: return newfg; } @@ -1005,6 +997,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, create_page_chain(class, zspage, pages); init_zspage(class, zspage); zspage->pool = pool; + zspage->class = class->index; return zspage; } @@ -1397,7 +1390,6 @@ unsigned long zs_malloc(struct zs_pool *pool, size_t size, gfp_t gfp) obj = obj_malloc(pool, zspage, handle); newfg = get_fullness_group(class, zspage); insert_zspage(class, zspage, newfg); - set_zspage_mapping(zspage, class->index, newfg); record_obj(handle, obj); atomic_long_add(class->pages_per_zspage, &pool->pages_allocated); class_stat_inc(class, ZS_OBJS_ALLOCATED, class->objs_per_zspage); @@ -1655,7 +1647,6 @@ static int putback_zspage(struct size_class *class, struct zspage *zspage) fullness = get_fullness_group(class, zspage); insert_zspage(class, zspage, fullness); - set_zspage_mapping(zspage, class->index, fullness); return fullness; } From patchwork Tue Feb 20 11:44:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 203572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp341902dyc; Tue, 20 Feb 2024 03:51:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUnrtguXkTngrPokB6mQ9RXFdaVCTCxbL6sZJwWaVJl/TbotHJ3kg+zqmqRuHkjbf+A0Jm/ixTnCPdHtls1QUtA2v4bHw== X-Google-Smtp-Source: AGHT+IE96rV5wBB8Hni6LiaQpNsuQ9QVbtNxfGo7G8RYh55OS1YcjRfSLxWEMBWIpTim6zWfrsgS X-Received: by 2002:a17:90b:4c4f:b0:299:3f84:41f2 with SMTP id np15-20020a17090b4c4f00b002993f8441f2mr8015446pjb.27.1708429898253; Tue, 20 Feb 2024 03:51:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708429898; cv=pass; d=google.com; s=arc-20160816; b=Es/aabsVIscqNhECSh0cCszSLVhx1GS/cbTPcvkbu0dBB6XGfgMRKkIGMaKb/TxrMu Kr0roOIoS450DYVdhrwykDlKFc1Yv+kXZCKMGQ+1wbHeRJpl/b2T4YdzOl2+iYyaaMkX h8H4obRRRR0XOR2bPdZzRAXi85WxaW1URXlJpyzBSJ3uyy7hGUmI2wMp8DF+1CmUfAtj /DCndNHSR+dvFiNBHJAsJts/PuQVrwOKE4HIC/48EEvVsdonIdJo7Sd38Zzml/w/A34H ibzS938bJ/FKJi1qJ5TIXFP9XL0nWexaiGiqPTQ75zGm76WIf+5QCiApchsTfGb2oEZ4 4cuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=ci79DiUWa7UnDzkerNUYQl6snYV1NrEQXPg7SGeMzMg=; fh=CIhmbM3N522iZfKAx68dio1DUnYohA/38dvKjB2Sibw=; b=dN7rqSyPb7PqKKAG/qSaYONKJLbgIHMFVWr9TzHFfqCfJfWG0lm1OfCbWOM1mYR9j3 NewUeWLDEU0Z5YkwlOweGKvwmwJWKadOQIhK+NTXgrYRgprUzZ8BkofCjy5d5YAxq5SV MAkMd7fT8TBvCWFXWUt6B6i9po+evYm9dmwjVynJYNKo8MmXfqEmYckM34DNqTb0tz5S ehJqLHGNruQBUp2RLMKAh/kd/S/OURQuwptCGgK0IPade/Xrv0XDWcWSN89Vxccd16hc Y0AoxIKact3GnsqZ25qWWHE06Spg+S27IEhNzsrFQyHM2VKLYLVW7noY5bWx/kIv0Uk7 d2EA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sFquOSfJ; 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-72932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72932-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o5-20020a635a05000000b005cecbe69c23si6153349pgb.43.2024.02.20.03.51.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 03:51:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sFquOSfJ; 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-72932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72932-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BF231B218A3 for ; Tue, 20 Feb 2024 11:45:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91A8567E7B; Tue, 20 Feb 2024 11:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="sFquOSfJ" Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (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 8D3C767C5B for ; Tue, 20 Feb 2024 11:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708429488; cv=none; b=hBQFwQa+TS7ZEH3HLkmO9i+mmYLllJH5YQ/5vkM9va8zPaPScyKeUiWpcM6jlOCwtFNLEelxKTUXDYzZlBUu0kMz0qOK5d9yapwGZxTPQ+7Uw/UuONRaj7xx3cf+X60R+Fl6jM7u6mU5UPxT8n+/iYNJ5EuQ9az+pkaqZei1Htw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708429488; c=relaxed/simple; bh=+hNOOnD6KYFH5W5qAnGzZngb3DqQxS5eWXbyLmHNF0g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CnBkASlfXkJz8mz1eUjPcKVur1/ZXT2FjB+lnWIgu0lS3V4grLim7uCAUAaxV/NmXC5jGWEVyNxHtB/BEmk2oXifNfryWM2BfeauqKz5bYXjGvv4W8ZeHpOPzBtH5/XhQUsBUeS8wLKi+DNqejtIzkAeAZ5ULZM8fYy4A6m9ljo= 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=sFquOSfJ; arc=none smtp.client-ip=95.215.58.180 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=1708429485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ci79DiUWa7UnDzkerNUYQl6snYV1NrEQXPg7SGeMzMg=; b=sFquOSfJAfNaMCcn09Pz5sjO2zdozOZHHOKnWpE+LDSMzXP7F23EP9QanRL77oXcAT277F FC0SYpH2l+d3i9aCwXkf2Azx5DhAJIYgQhIpB19q7jstT7MPGibYDvOKlG4K6U8vBu87Ju bRtPc7aXmlSDbI5CnxSzfSZECVV6PY8= From: Chengming Zhou Date: Tue, 20 Feb 2024 11:44:31 +0000 Subject: [PATCH RESEND 3/3] mm/zsmalloc: remove get_zspage_mapping() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240220-b4-zsmalloc-cleanup-v1-3-b7e9cbab9541@linux.dev> References: <20240220-b4-zsmalloc-cleanup-v1-0-b7e9cbab9541@linux.dev> In-Reply-To: <20240220-b4-zsmalloc-cleanup-v1-0-b7e9cbab9541@linux.dev> To: hannes@cmpxchg.org, Andrew Morton , Sergey Senozhatsky , nphamcs@gmail.com, yosryahmed@google.com, Minchan Kim Cc: linux-mm@kvack.org, Chengming Zhou , linux-kernel@vger.kernel.org X-Developer-Signature: v=1; a=ed25519-sha256; t=1708429476; l=2848; i=chengming.zhou@linux.dev; s=20240220; h=from:subject:message-id; bh=Xgdlm55CLoh7bhkT80TmmQFtvDTRQ4HP1+zxTxJBYgU=; b=6L4Rze0bnsKiqR9+QLqh2qD7BDtQUhtZu8ueGs9RPgzByahXpM+6pkTSsBD1omm7SA3abUFN5 ZTBlKgut6b+DoJxWVUkh0tjpPfx/6AV6Utfx4wSudSlGuNzInKTxDcM X-Developer-Key: i=chengming.zhou@linux.dev; a=ed25519; pk=5+68Wfci+T30FoQos5RH+hfToF6SlC+S9LMPSPBFWuw= X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791418589033830883 X-GMAIL-MSGID: 1791418589033830883 From: Chengming Zhou Actually we seldom use the class_idx returned from get_zspage_mapping(), only the zspage->fullness is useful, just use zspage->fullness to remove this helper. Note zspage->fullness is not stable outside pool->lock, remove redundant "VM_BUG_ON(fullness != ZS_INUSE_RATIO_0)" in async_free_zspage() since we already have the same VM_BUG_ON() in __free_zspage(), which is safe to access zspage->fullness with pool->lock held. Signed-off-by: Chengming Zhou Reviewed-by: Sergey Senozhatsky --- mm/zsmalloc.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index c39fac9361d7..63ec385cd670 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -470,16 +470,6 @@ static inline void set_freeobj(struct zspage *zspage, unsigned int obj) zspage->freeobj = obj; } -static void get_zspage_mapping(struct zspage *zspage, - unsigned int *class_idx, - int *fullness) -{ - BUG_ON(zspage->magic != ZSPAGE_MAGIC); - - *fullness = zspage->fullness; - *class_idx = zspage->class; -} - static struct size_class *zspage_class(struct zs_pool *pool, struct zspage *zspage) { @@ -708,12 +698,10 @@ static void remove_zspage(struct size_class *class, struct zspage *zspage) */ static int fix_fullness_group(struct size_class *class, struct zspage *zspage) { - int class_idx; - int currfg, newfg; + int newfg; - get_zspage_mapping(zspage, &class_idx, &currfg); newfg = get_fullness_group(class, zspage); - if (newfg == currfg) + if (newfg == zspage->fullness) goto out; remove_zspage(class, zspage); @@ -835,15 +823,11 @@ static void __free_zspage(struct zs_pool *pool, struct size_class *class, struct zspage *zspage) { struct page *page, *next; - int fg; - unsigned int class_idx; - - get_zspage_mapping(zspage, &class_idx, &fg); assert_spin_locked(&pool->lock); VM_BUG_ON(get_zspage_inuse(zspage)); - VM_BUG_ON(fg != ZS_INUSE_RATIO_0); + VM_BUG_ON(zspage->fullness != ZS_INUSE_RATIO_0); next = page = get_first_page(zspage); do { @@ -1857,8 +1841,6 @@ static void async_free_zspage(struct work_struct *work) { int i; struct size_class *class; - unsigned int class_idx; - int fullness; struct zspage *zspage, *tmp; LIST_HEAD(free_pages); struct zs_pool *pool = container_of(work, struct zs_pool, @@ -1879,10 +1861,8 @@ static void async_free_zspage(struct work_struct *work) list_del(&zspage->list); lock_zspage(zspage); - get_zspage_mapping(zspage, &class_idx, &fullness); - VM_BUG_ON(fullness != ZS_INUSE_RATIO_0); - class = pool->size_class[class_idx]; spin_lock(&pool->lock); + class = zspage_class(pool, zspage); __free_zspage(pool, class, zspage); spin_unlock(&pool->lock); }