Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp481960lqc; Fri, 8 Mar 2024 03:26:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUak+3pvjEyxmAjYHkqX55Zlp+kZYCX/Ou+Sha4bunP5xy8Io3usSyKBiDGQM3viVbfexCvFCoQ/0BMDQcnyvvo756/Wjt7Iorv+YxVzg== X-Google-Smtp-Source: AGHT+IFmkWhYegLQadTtISUOPJBx/wqp48cIa43j4F3yO3gcDCfIikYRyY1JHl9/bkbm7Sx0kUEk X-Received: by 2002:a54:470d:0:b0:3c1:e9bf:dd91 with SMTP id k13-20020a54470d000000b003c1e9bfdd91mr9748735oik.54.1709897193662; Fri, 08 Mar 2024 03:26:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709897193; cv=pass; d=google.com; s=arc-20160816; b=BVglut06JCpzKwKU3IfKG5DuYIYoF3LO97RrqBQcg9r4WByUwDuh84HGzKLx6bBLFS uTQPLxWD9dqBe9GBCm7mkY+jgWn37ca2/vk9Xx0hHftCDQBbxnMtoDPFsRWwIAFrYgt9 +PzB79DMZ3psuW/b9Wobpdt0AXHtingSKog2EJvYoX/FKTAzGGt2FnGuVHcLLMKsJ7dR dBnxJRYYpxHHbpZBjbXAwnToGGX+4J9Wk1Zla0Eqb5DiFIaaQQ3G1fkdiSIKERZCKL7t zYhj09yD10gre7z3DrjJ4paapN6ZAGpcTc9+S9+HWJmCUviuG8wxH60Q6oSldJZeYpmo mZ8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=xDOP/HY6fUBY0kDDyOdRYDuOjFs4RGRvDdATH2L2AtI=; fh=cwfL33CUqeeOYukaawhXq8dKX5vBmQuk3Ej+ofuDjUc=; b=GyFKrZeAlCVBPde1wFAa9DUuq6vND6wf4QLV+l2eoCvX2MBkbPSicPiBDAALPuNSCz Mx99xpEYmi3xKNeC48usCVRSW+otMCMnR+FpZmss4wj3AiaE/VxuQU1C6cUKHLuZ/ct3 v+nT31vJHonFl7hLDgi5z+I1sDYDEhriBGXnTBKoN+IQaZErtyP9Az/6fUO2x0aPR8JF M7j/WUUk3p1CpHS0R+QVVGBohExn+tPX4ZBs5JRV8jJw1OgSivBj5zpc7QwdAGZg9Ugx qCB/RA0HOCYroO90YSAlVW1imFOKYRW/TAsFjvFolzTEOdtRLMlUlBlHDVLytQGPDGLs 8vlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gondor.apana.org.au dmarc=pass fromdomain=gondor.apana.org.au); spf=pass (google.com: domain of linux-crypto+bounces-2585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=QUARANTINE dis=QUARANTINE) header.from=apana.org.au Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o28-20020a63731c000000b005dc5061f211si16136442pgc.560.2024.03.08.03.26.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 03:26:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gondor.apana.org.au dmarc=pass fromdomain=gondor.apana.org.au); spf=pass (google.com: domain of linux-crypto+bounces-2585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=QUARANTINE dis=QUARANTINE) header.from=apana.org.au 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 52DC1283B73 for ; Fri, 8 Mar 2024 11:26:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1831F5644D; Fri, 8 Mar 2024 11:26:02 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) (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 E09E255E41; Fri, 8 Mar 2024 11:25:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=144.6.53.87 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709897161; cv=none; b=UuAlVdprrE7/tZsbGFPKY+WlF/m8L4E3FGsGbG0P1rPDh9z93WH8byYdNpg7skmpXPZ9Cpt90a1VW9mRxP16o2eBSRKM3y5TlQlw/H/24hutc034ApSLOD77s8lyNInSzP1lUiF1sA2ut5gUT8HVeA8Hcz9n6SfQDo3KcIxe0PQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709897161; c=relaxed/simple; bh=LkmHQ2b6nr4TsS0uvCucBj9bQUuf42FRBtmn439zrdM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jdqVFwf7KndoHUCdDHSYGUeFpz1OVKnezbYfXv+ssUB51wiQsk5AwVLpwPv9C4MJk9l6fGclTkDBvV4SexA5/8wMzxXSvHaEF5TK+Bq4XyrE9WNbUO4ZZy6eM+CMhlHEko2DOjTV/aPUbnh68imRqcfgNxO8vy4VB3TDkp9dIQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gondor.apana.org.au; spf=pass smtp.mailfrom=gondor.apana.org.au; arc=none smtp.client-ip=144.6.53.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gondor.apana.org.au Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1riYME-004tLx-H8; Fri, 08 Mar 2024 19:25:47 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 08 Mar 2024 19:26:02 +0800 Date: Fri, 8 Mar 2024 19:26:02 +0800 From: Herbert Xu To: Barry Song <21cnbao@gmail.com> Cc: davem@davemloft.net, linux-crypto@vger.kernel.org, akpm@linux-foundation.org, chrisl@kernel.org, sjenning@redhat.com, vitaly.wool@konsulko.com, linux-kernel@vger.kernel.org, Barry Song , Johannes Weiner , Nhat Pham , Yosry Ahmed , Chengming Zhou Subject: Re: [PATCH v7] crypto: scompress: remove memcpy if sg_nents is 1 and pages are lowmem Message-ID: References: <20240301192745.14987-1-21cnbao@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240301192745.14987-1-21cnbao@gmail.com> On Sat, Mar 02, 2024 at 08:27:45AM +1300, Barry Song wrote: > From: Barry Song > > while sg_nents is 1, which is always true for the current kernel > as the only user - zswap is this case, we might have a chance to > remove memcpy, thus improve the performance. > Though sg_nents is 1, its buffer might cross two pages. If those > pages are highmem, we have no cheap way to map them to contiguous > virtual address because kmap doesn't support more than one page > (kmap single higmem page could be still expensive for tlb) and > vmap is expensive. > So we also test and enure page is not highmem in order to safely > use page_to_virt before removing the memcpy. The good news is > that in the most majority of cases, we are lowmem, and we are > always lowmem in those modern and popular hardware. > > Cc: Johannes Weiner > Cc: Nhat Pham > Cc: Yosry Ahmed > Signed-off-by: Barry Song > Tested-by: Chengming Zhou > --- > -v7: > * fix the problem pointed out by Herbert - flush all pages if dst > is longer than one page. > > crypto/scompress.c | 36 +++++++++++++++++++++++++++++------- > 1 file changed, 29 insertions(+), 7 deletions(-) Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt