From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52E00C47404 for ; Mon, 7 Oct 2019 12:48:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 177C520867 for ; Mon, 7 Oct 2019 12:48:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="f4HDQY4m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfJGMsc (ORCPT ); Mon, 7 Oct 2019 08:48:32 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:53240 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727566AbfJGMsc (ORCPT ); Mon, 7 Oct 2019 08:48:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wMm+Q1AQe3MKdu1giulBb8H+6dom7FXD4ybaYMRdbw4=; b=f4HDQY4mke2eSnFVGRilAYEPh PjWN+ZElO60g7xKKzWqDptByI0V5WdlXF2OZegEQmNoiVqEUsN4Ac7OktaLK2MBNZwTzUbKDVH6m/ 2bNT5UEF5W2k892ynRYWRIJGRTLZiNRAqXfgMusUObIUp+B3p+l4btEtEFYZYq4A9IMSWbg4/LocT /U3i+BVq3YD2E/ovLyR6X0wXFKqUoExvHpKM0Bc4ySfUrCVZZwUTll3rPIpbG9CAke8uAuUwidzeU 0SHPlfYXHt+UZiEoaKFQDHv0IHg1EbN4JY7cCcbi3nmSbOEUpUy9vgs+LKKE8aj1XVMaPFQcmWkTR VA2UnvGmw==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iHSRD-00066o-FJ; Mon, 07 Oct 2019 12:48:31 +0000 Date: Mon, 7 Oct 2019 05:48:31 -0700 From: Christoph Hellwig To: Leon Romanovsky Cc: Christoph Hellwig , Doug Ledford , Jason Gunthorpe , RDMA mailing list , Or Gerlitz , Yamin Friedman , Saeed Mahameed , linux-netdev Subject: Re: [PATCH rdma-next v1 2/3] RDMA/rw: Support threshold for registration vs scattering to local pages Message-ID: <20191007124831.GA20840@infradead.org> References: <20191007115819.9211-1-leon@kernel.org> <20191007115819.9211-3-leon@kernel.org> <20191007121244.GA19843@infradead.org> <20191007123656.GW5855@unreal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191007123656.GW5855@unreal> User-Agent: Mutt/1.12.1 (2019-06-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Mon, Oct 07, 2019 at 03:36:56PM +0300, Leon Romanovsky wrote: > > > if (rdma_protocol_iwarp(dev, port_num) && dir == DMA_FROM_DEVICE) > > > return true; > > > + if (dev->attrs.max_sgl_rd && dir == DMA_FROM_DEVICE && > > > + dma_nents > dev->attrs.max_sgl_rd) > > > + return true; > > > > This can be simplified to: > > > > if (dir == DMA_FROM_DEVICE && > > (rdma_protocol_iwarp(dev, port_num) || > > (dev->attrs.max_sgl_rd && dma_nents > dev->attrs.max_sgl_rd))) > > return true; > > I don't think that it simplifies and wanted to make separate checks to > be separated. For example, rdma_protocol_iwarp() has nothing to do with > attrs.max_sgl_rd. The important bit is to have the DMA_FROM_DEVICE check only once, as we only do the registration for reads with either parameter. So if you want it more verbose the wya would be: if (dir == DMA_FROM_DEVICE) { if (rdma_protocol_iwarp(dev, port_num)) return true; if (dev->attrs.max_sgl_rd && dma_nents > dev->attrs.max_sgl_rd) return true; }