From patchwork Tue Oct 1 17:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pintu Kumar X-Patchwork-Id: 13818609 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 F1A43CEACF1 for ; Tue, 1 Oct 2024 17:54:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 418D92800CD; Tue, 1 Oct 2024 13:54:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C8E52800CC; Tue, 1 Oct 2024 13:54:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2692C2800CD; Tue, 1 Oct 2024 13:54:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 03F402800CC for ; Tue, 1 Oct 2024 13:54:33 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 76D52C185F for ; Tue, 1 Oct 2024 17:54:33 +0000 (UTC) X-FDA: 82625783226.12.CFF41F4 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf19.hostedemail.com (Postfix) with ESMTP id 5AA3D1A0007 for ; Tue, 1 Oct 2024 17:54:31 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b="LT 8PGcy"; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf19.hostedemail.com: domain of quic_pintu@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_pintu@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727805177; a=rsa-sha256; cv=none; b=7Gvq6AaOM/eXJqJ/o/c0g28YA4cJj2gD9bg7s0fizPfwsRQZDu9L2EwuO+UJsjCtNJbovy DvPcG6ZYuzelsqyMm84YwGm0X43UlkkiZBR+5cBXF3T82CcFhK06zD12MptpNVK6AwYWyT z20hTYxqPadv+G7djpXQE8gUoNr8psU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b="LT 8PGcy"; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf19.hostedemail.com: domain of quic_pintu@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_pintu@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727805177; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=FD3EhqA3CYSccYK1CMSE9VY0pQmd+OHP+KzHPvAuot4=; b=o0qNKq2V6cP5l/VNFQ3R+H04FIuOKcoIzNcTfN4wDD4tP8WdpkJN7CwQpL7oJoe4d7Kh2k n3j2wlxmv3GAv1IQ0Rr5+Sh1cHx5DP0Hc/yIcKeZm7du62uP9HnB2PIZkRj1fZeY/0Bf6Z 51QUxeea05ea/d5QK2bg+LXpwmwwlV0= Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 491AUsor001779; Tue, 1 Oct 2024 17:54:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:message-id:mime-version:subject:to; s= qcppdkim1; bh=FD3EhqA3CYSccYK1CMSE9VY0pQmd+OHP+KzHPvAuot4=; b=LT 8PGcyN6j1tE7dYEqf73kaKyXBf89tMrCIkC1Y2pjtBeug8pcMEjJFfsGH5OWMl+c g4e7dZar1XmWWQitAWVmwJPO9rPWWaaVNVYxgAuU2SbY0dTUzmkI6ewTKvr/MfaN Va7/MYaTA5pTjnJlsWUEfsAjtgZmey8amyPruyKKuYqNkCXmIrTNsis5rwZuTyLe rcHmws5qdZRYIPudDrhvYvziDEANUqCZhTiHLGT+AEViF4gIk89yJft9cvFSx8+D K3gc3cwVhEp5DqVWAI3mXbFUyNDjdZ1lmiQ0vOaKFCRufUk1J4XuvVkWXouK3dT/ IWu+N6y6vUDdKu0zBGWg== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41xa12satj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Oct 2024 17:54:26 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 491HsPqf017680 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 1 Oct 2024 17:54:25 GMT Received: from hu-pintu-blr.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 1 Oct 2024 10:54:22 -0700 From: Pintu Kumar To: , , , , CC: , , , Pintu Kumar Subject: [PATCH 3/3] zsmalloc: replace kmap_atomic with kmap_local_page Date: Tue, 1 Oct 2024 23:23:58 +0530 Message-ID: <20241001175358.12970-1-quic_pintu@quicinc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 8Tx1oWPSCC50INi9GFs6M_rXXI_i8tJ5 X-Proofpoint-GUID: 8Tx1oWPSCC50INi9GFs6M_rXXI_i8tJ5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=693 impostorscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 bulkscore=0 malwarescore=0 spamscore=0 clxscore=1011 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2410010115 X-Rspamd-Queue-Id: 5AA3D1A0007 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ask99wpp5bipmn4hz549utnd7cgm5bbz X-HE-Tag: 1727805271-537099 X-HE-Meta: U2FsdGVkX185yhGd/aeFUyq0qAeRUC2Wd15BF4fZuaRAQ25DCY2SYJ8qpoDjdzxnaRG3tTm/NYWvP/6GY7s9zOUZ5okpW7iIBFeJJB5GXv3VOWt2pB/N5gmbKr/ihpBX6rgxoqhmsfbfPeL6e5c/Of3OJNTGZkrE+9IJCM7Duylb9ArGQEiKTOSBdEXGcodahs5emn1EIYRDS6RU/m0LNot8BUEa0tNAoaSxaTE/tu8drgZUgzLgWdyFcKrA3+yjf1gcpTxC2JDVrUEsLhN9JnYSf7JENkcofC94WD/E+gO/miiiBbZOWtNljvDzneGJkUr9jntbYSAec8oBtLf4+/BK0JVtHHvW+0xhLrnyns4LxD837WBGeHe4cPg3Ue9EJsVIkeWMQ1IEHYz/zgnf3J1idrxql5Mlzy1TU01lpf9BfKNUXRsQb4RtSRbHLmSWVy568Ax0pVBtWZlgcuK2xAzYrwQwY5mQvJjrL5S83gvr0rf7SOw09wqBUhFkM6tpyu3Z3Mhc2oOMBu8pGUgnHAzzu+Gpg6AP/LkJzlaC0wWDXrVR0Lovia7CO3dmdh2lj+w+LlDkMXV89mAUJdGJptSX8ZxrpPrlGnDCntrRj3qk4OrmgfT0PvhvlxHFKT9RG5UHgU4F9HT7fK8qihXqWRHFuUKFWrGZdd/R6TxkT+qrQs1gFS04ssciZya1lmeB9/uP8byfIOqZrX/Fu7K6PzavaRAVJIaTVvi2I4QPYakj6ujtrbY39SoXwJfueqkjdOZBUl9KmyLgqJIi+wuJhBlxnCSrEV8yg9y095xxOoH+ZPhklVCQBIuw4Y0BY9gVx+TWjbAaZ5GO1l+mw0opIMImuBhcJ5fCh2bycxxtQOuDgunnQPqkmRvwvZvbudhPonR6nVDS6a2FQFB9MROWRSLxGdCvwtr1LXOWeDUNQPh8+cCn3spuzSnILQ7NkJvHLgJ2zH0ly45sWX+hlKm obL3RS74 3E8I7ODsU4zuHM/+T0+7cmDkDAkklrMM7WzT1hqiHm6LBgVrPcYDAq8Q8JorEubgHp1b5DHP0g8bLAtam32EIlPMn9S4XRcUWYQiHoFU46f2VDmF8nb0MOO+2xCQ1Ba7NX64XLfrxylsxq5Qz+PrED+33fTVdJ3pw5YkCjfBEqZE0h++8h2LHBwDczw44JvhA+wT37dhhJHfLYOYNTBLHvqkL6JEVAg3sTyfHApFOVoMKuZmWlu/BJicf5DY7hj92CTi6KYzgLWblDO+xLNRAA9xjWBvB3WRQcUFnrs28hG0EPmlKTb7uueHL8WJfclJN911keqXs8G3ce8tYtSzaJ/iUawsGTO0zRQYU4G2aSEMsh9eLN7qew+0E2yh5YnV76hhn+EKPxS+VtSU= 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: List-Subscribe: List-Unsubscribe: The use of kmap_atomic/kunmap_atomic is deprecated. Replace it will kmap_local_page/kunmap_local all over the place. Also fix SPDX missing license header. WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead + vaddr = kmap_atomic(page); Signed-off-by: Pintu Kumar --- mm/zsmalloc.c | 66 ++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 16a07def09c9..d3ff10160a5f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + /* * zsmalloc memory allocator * @@ -898,7 +900,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) set_first_obj_offset(page, off); - vaddr = kmap_atomic(page); + vaddr = kmap_local_page(page); link = (struct link_free *)vaddr + off / sizeof(*link); while ((off += class->size) < PAGE_SIZE) { @@ -921,7 +923,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) */ link->next = -1UL << OBJ_TAG_BITS; } - kunmap_atomic(vaddr); + kunmap_local(vaddr); page = next_page; off %= PAGE_SIZE; } @@ -1059,12 +1061,12 @@ static void *__zs_map_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy object to per-cpu buffer */ - addr = kmap_atomic(pages[0]); + addr = kmap_local_page(pages[0]); memcpy(buf, addr + off, sizes[0]); - kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + kunmap_local(addr); + addr = kmap_local_page(pages[1]); memcpy(buf + sizes[0], addr, sizes[1]); - kunmap_atomic(addr); + kunmap_local(addr); out: return area->vm_buf; } @@ -1089,12 +1091,12 @@ static void __zs_unmap_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy per-cpu buffer to object */ - addr = kmap_atomic(pages[0]); + addr = kmap_local_page(pages[0]); memcpy(addr + off, buf, sizes[0]); - kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + kunmap_local(addr); + addr = kmap_local_page(pages[1]); memcpy(addr, buf + sizes[0], sizes[1]); - kunmap_atomic(addr); + kunmap_local(addr); out: /* enable page faults to match kunmap_atomic() return conditions */ @@ -1223,7 +1225,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, area->vm_mm = mm; if (off + class->size <= PAGE_SIZE) { /* this object is contained entirely within a page */ - area->vm_addr = kmap_atomic(page); + area->vm_addr = kmap_local_page(page); ret = area->vm_addr + off; goto out; } @@ -1260,7 +1262,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) area = this_cpu_ptr(&zs_map_area); if (off + class->size <= PAGE_SIZE) - kunmap_atomic(area->vm_addr); + kunmap_local(area->vm_addr); else { struct page *pages[2]; @@ -1318,7 +1320,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, for (i = 0; i < nr_page; i++) m_page = get_next_page(m_page); - vaddr = kmap_atomic(m_page); + vaddr = kmap_local_page(m_page); link = (struct link_free *)vaddr + m_offset / sizeof(*link); set_freeobj(zspage, link->next >> OBJ_TAG_BITS); if (likely(!ZsHugePage(zspage))) @@ -1328,7 +1330,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, /* record handle to page->index */ zspage->first_page->index = handle | OBJ_ALLOCATED_TAG; - kunmap_atomic(vaddr); + kunmap_local(vaddr); mod_zspage_inuse(zspage, 1); obj = location_to_obj(m_page, obj); @@ -1419,7 +1421,7 @@ static void obj_free(int class_size, unsigned long obj) f_offset = offset_in_page(class_size * f_objidx); zspage = get_zspage(f_page); - vaddr = kmap_atomic(f_page); + vaddr = kmap_local_page(f_page); link = (struct link_free *)(vaddr + f_offset); /* Insert this object in containing zspage's freelist */ @@ -1429,7 +1431,7 @@ static void obj_free(int class_size, unsigned long obj) f_page->index = 0; set_freeobj(zspage, f_objidx); - kunmap_atomic(vaddr); + kunmap_local(vaddr); mod_zspage_inuse(zspage, -1); } @@ -1492,8 +1494,8 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, if (d_off + class->size > PAGE_SIZE) d_size = PAGE_SIZE - d_off; - s_addr = kmap_atomic(s_page); - d_addr = kmap_atomic(d_page); + s_addr = kmap_local_page(s_page); + d_addr = kmap_local_page(d_page); while (1) { size = min(s_size, d_size); @@ -1516,26 +1518,26 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, * Documentation/mm/highmem.rst. */ if (s_off >= PAGE_SIZE) { - kunmap_atomic(d_addr); - kunmap_atomic(s_addr); + kunmap_local(d_addr); + kunmap_local(s_addr); s_page = get_next_page(s_page); - s_addr = kmap_atomic(s_page); - d_addr = kmap_atomic(d_page); + s_addr = kmap_local_page(s_page); + d_addr = kmap_local_page(d_page); s_size = class->size - written; s_off = 0; } if (d_off >= PAGE_SIZE) { - kunmap_atomic(d_addr); + kunmap_local(d_addr); d_page = get_next_page(d_page); - d_addr = kmap_atomic(d_page); + d_addr = kmap_local_page(d_page); d_size = class->size - written; d_off = 0; } } - kunmap_atomic(d_addr); - kunmap_atomic(s_addr); + kunmap_local(d_addr); + kunmap_local(s_addr); } /* @@ -1548,7 +1550,7 @@ static unsigned long find_alloced_obj(struct size_class *class, unsigned int offset; int index = *obj_idx; unsigned long handle = 0; - void *addr = kmap_atomic(page); + void *addr = kmap_local_page(page); offset = get_first_obj_offset(page); offset += class->size * index; @@ -1561,7 +1563,7 @@ static unsigned long find_alloced_obj(struct size_class *class, index++; } - kunmap_atomic(addr); + kunmap_local(addr); *obj_idx = index; @@ -1798,14 +1800,14 @@ static int zs_page_migrate(struct page *newpage, struct page *page, migrate_write_lock(zspage); offset = get_first_obj_offset(page); - s_addr = kmap_atomic(page); + s_addr = kmap_local_page(page); /* * Here, any user cannot access all objects in the zspage so let's move. */ - d_addr = kmap_atomic(newpage); + d_addr = kmap_local_page(newpage); copy_page(d_addr, s_addr); - kunmap_atomic(d_addr); + kunmap_local(d_addr); for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { @@ -1818,7 +1820,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, record_obj(handle, new_obj); } } - kunmap_atomic(s_addr); + kunmap_local(s_addr); replace_sub_page(class, zspage, newpage, page); /*