From mboxrd@z Thu Jan 1 00:00:00 1970 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 BFE986BB21; Fri, 1 Mar 2024 10:27:54 +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=1709288878; cv=none; b=jl8MpyNDK8+2iSBDBusaHpbKCJrmZITG4ZePrExjwjsQh0Cy6QH/utW4PFrk8y9rRKaOOWFfOMpJ6i+s/8bMTitutjmHxQSCvm1Vca2GIbX0haw6edX6l6T/GOeukYtWB2Xq4N8XKEfLLbLfXoScpPjfaN1SsoEEToFzCmMF5+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709288878; c=relaxed/simple; bh=iy39Q0PmbCSReLq/Ws6hOu/z5TtI9QjD98GQOJha/pY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ccYUvey7Q43tzrtwVpBcLKWQwm/ZkPpArFM1uX+Se0MuIzIrrf7Ujy8YXYOc/YNgaKDSW8kAgu82AaIQ1m+CktFXBgFPhntiVHSemZfZZd6xmTK3PcUOvAH6YcHNHCmiMHScfM2lV8bxGPEaP7SRIIsIQMG2Tfi9Ii/rCvAYFGM= 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 1rg07D-002H41-In; Fri, 01 Mar 2024 18:27:44 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 01 Mar 2024 18:27:58 +0800 Date: Fri, 1 Mar 2024 18:27:58 +0800 From: Herbert Xu To: Barry Song <21cnbao@gmail.com> Cc: davem@davemloft.net, linux-crypto@vger.kernel.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, hannes@cmpxchg.org, chriscli@google.com, chrisl@kernel.org, sjenning@redhat.com, vitaly.wool@konsulko.com, Barry Song , Nhat Pham , Yosry Ahmed , Chengming Zhou , Matthew Wilcox , Kent Overstreet , "Darrick J. Wong" , Christoph Hellwig , Al Viro Subject: Re: [PATCH v6] crypto: scompress: remove memcpy if sg_nents is 1 and pages are lowmem Message-ID: References: <20240222020617.31041-1-21cnbao@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <20240222020617.31041-1-21cnbao@gmail.com> On Thu, Feb 22, 2024 at 03:06:17PM +1300, Barry Song wrote: > > - scatterwalk_map_and_copy(scratch->src, req->src, 0, req->slen, 0); > + if (sg_nents(req->src) == 1 && !PageHighMem(sg_page(req->src))) { > + src = page_to_virt(sg_page(req->src)) + req->src->offset; Incidentally this made me look at other uses of PageHighMem in the kernel. The one in copy_page_from_iter_atomic looks buggy because it assumes that the kmap never maps a page if PageHighMem is false, which is not the case for CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP. > @@ -152,8 +165,12 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir) > ret = -ENOSPC; > goto out; > } > - scatterwalk_map_and_copy(scratch->dst, req->dst, 0, req->dlen, > - 1); > + if (dst == scratch->dst) { > + scatterwalk_map_and_copy(scratch->dst, req->dst, 0, > + req->dlen, 1); > + } else { > + flush_dcache_page(sg_page(req->dst)); I think this is still wrong for the > PAGE_SIZE case. The existing code flushes each page sequentially but the new code only flushes the first page. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt