Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5092339rwb; Wed, 17 Aug 2022 10:55:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR6qbkORRuou4Rl0GSYWP5taiqooPVtst7lCbymBfIx78Yrfk85oLLwZxwsX9DUuBrgiZMLa X-Received: by 2002:a05:6a00:15c7:b0:52e:5a5d:27fa with SMTP id o7-20020a056a0015c700b0052e5a5d27famr26701888pfu.52.1660758905183; Wed, 17 Aug 2022 10:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660758905; cv=none; d=google.com; s=arc-20160816; b=aqGPuJ+G2HLWCbYZUBhyVXwgsYYh/1fy3MMEVmKauDIDNBeJHjeBSRgIfxVclWh7kw wfM3nYxOlbY5wuEvPwVYJpDvl9mn//ssYs+Z77iP7ZfoBnfmOSBmDYxyFxBJ0bkYq0FN +IoTaH22MfYX9Ud+7cZtSVAI2Xta5YUwsPOM9DlC7v4Zv2CMtGhMrEsfNSctReT9KsNG 8bTJ42nKUPULAl6Yt6gbeKtlZE9YpFF+aQMZUM2J6wYOKkOVxWsLxLZcaU0cNQBbfPhx 45Sr5eS3VQakFCLu3ElT5DbkX3MJedFo1Gwabyp+meG++IAexx9ZHM7oWbDIHcwHAAbz Ez4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jxRSULSnQ9AB4xZze/zzmA4j0sE1oXfkxcYBXxS9T8c=; b=gKnp4sKWY/GT9/PhES9fzUhrK/f8VjFKpr+TjqXLniNim0+tvQAZECxYE94v9HqCyV wa2lEa5LWoskw/dbAlCPMsZwAbnxELb+4m+8FQoI0cC4t6lWJPxfZUNNIpJxqavnnKtf tnFmAGCSKtXKbbLN1dV8KAyK9wMFK39ZANRTxlLrRNePvbsEuwwQcEaHyFz6pXJelBR8 xzUN5GzqXNsjleQUjFQwJx/R7X+TDC2OiT2WyAjawnysnfZAIW3sbv41QMJx64ivPWE0 gWh31fCAlfx6oQM6IZEuQ2I3hhE59M77yiYWGwc6EtUg4zyU+0DRcA2O9f502SUe5LAk Vv2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FaAsS1i2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d190-20020a6368c7000000b004298f40081fsi6656145pgc.313.2022.08.17.10.54.52; Wed, 17 Aug 2022 10:55:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FaAsS1i2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237558AbiHQRob (ORCPT + 99 others); Wed, 17 Aug 2022 13:44:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240683AbiHQRo2 (ORCPT ); Wed, 17 Aug 2022 13:44:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81E524620B for ; Wed, 17 Aug 2022 10:44:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D28CC6130D for ; Wed, 17 Aug 2022 17:44:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A9D2C433D6; Wed, 17 Aug 2022 17:44:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660758264; bh=RUGwvuAQRArCjX8ifHZubqA3C7OTKG3kXa4gkAdYYas=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FaAsS1i2+0FDOsoI5r001GJsjskp84fnvr18WAj/ayy2ejW6ey0HCpfTWmU0OwzJ3 T2MFHduv1IihnTQhcnIAJsnGBsw4GBpQEnJGcQUk42V3Z1MxsIChB14ZmcXb76Avng HtIxCuQeFmNI94yfoU5enj+DJKS+cI0C9H5i+hR1I60xyImpwWhelumNno+JJe38KM 0fw91lFhKrjYki+AezrQbc3g/cFbzFJmDxMF2aDRLFGMfA6DFuCmREPpgPD4hQWh/m Zk7GP594ZQ9YMq6bIDQUOfY7ryARPwGwEQhHdAjUSL0/hOU05/gDmbB0aGZCholtrJ S6MDGtZp4w5NA== Date: Wed, 17 Aug 2022 11:44:20 -0600 From: Keith Busch To: "Fabio M. De Francesco" Cc: Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Chaitanya Kulkarni , Ira Weiny Subject: Re: [PATCH] nvmet-tcp: Don't kmap() pages which can't come from HIGHMEM Message-ID: References: <20220817170427.15682-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220817170427.15682-1-fmdefrancesco@gmail.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 17, 2022 at 07:04:27PM +0200, Fabio M. De Francesco wrote: > @@ -329,7 +312,6 @@ static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd) > u32 length, offset, sg_offset; > > length = cmd->pdu_len; > - cmd->nr_mapped = DIV_ROUND_UP(length, PAGE_SIZE); > offset = cmd->rbytes_done; > cmd->sg_idx = offset / PAGE_SIZE; > sg_offset = offset % PAGE_SIZE; > @@ -338,7 +320,7 @@ static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd) > while (length) { > u32 iov_len = min_t(u32, length, sg->length - sg_offset); > > - iov->iov_base = kmap(sg_page(sg)) + sg->offset + sg_offset; > + iov->iov_base = page_address(sg_page(sg)) + sg->offset + sg_offset; > iov->iov_len = iov_len; > > length -= iov_len; > @@ -347,8 +329,7 @@ static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd) > sg_offset = 0; > } > > - iov_iter_kvec(&cmd->recv_msg.msg_iter, READ, cmd->iov, > - cmd->nr_mapped, cmd->pdu_len); > + iov_iter_kvec(&cmd->recv_msg.msg_iter, READ, cmd->iov, 0, cmd->pdu_len); > } I earlier meant just use a local variable for 'nr_mapped' rather than replace it with '0'. I don't think that 0 segments would result in usable kvec. I'm not even sure the existing code is correct, though. The sg->length can be higher order than a PAGE_SIZE, so it may be over-reporting nr_segs. It's just supposed to be the number of initialized iov's. Anway, the rest looks good.