Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1886054imm; Thu, 2 Aug 2018 02:43:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdlCfZg2c/kEhEq4WDdrGlubgGVFx2RKLioPmeOhW9sGAd65LYNEI4twESNPkxxFMzJ9duv X-Received: by 2002:a17:902:7894:: with SMTP id q20-v6mr1760675pll.3.1533202994250; Thu, 02 Aug 2018 02:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533202994; cv=none; d=google.com; s=arc-20160816; b=sGhYpy3Xli8IChuNGP6Hfs8SVlUaxvzXRjqO6LWaKohWy8oEzmjfnTHAHn2QoOnRcc lFo3Pe+2jKGDKJJ7Nh4Nt9COw8giPCvdxXoZqFAeh/5haH0xDAnAQRpOpOgVaQZJjf5L FSV5D56vdT97bDUFvSdxdiHOwF9DyR7hB4DfYimaFUwIWf8Y184evTjmhsYvJm8OEhoH Rr3S9rM4tobw+6oZU/yQE2i2jvQpvRuhKzeGgVDXmKQJWSucp4myWqzBnQwNYP+I93eE /ROA4D8cJUjoeiJerQSRZHVOSpGUsYhsFR/hb+iZkO5B4O35JciwTzQ0XIHMq7bdbzkU yq2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=ooj6P0EP8tkXQBoym9Jh0jMZKOGKYfWrftzBc0CTGos=; b=PkvUt2jUTEOhc7onMxyTxjpuaMDMLecMDS46JgTZFFR+IvkCB75AVbebBzCGkCVDDG jEfnUFSyMwECi8FQnnmDUNdn+Aa+yBM3PWc2GSmgQ9XMzvgiwjECf5f4tYxzjBFrYoeq dbdjOpVdnoQ6T+kamIqZ+s9Atry/SknFQpW3MsPHPDE/sxk/k8IQlm1x2sDxfQ1QlPlF K1C44e1jEzC5EbbU9bO5cnAOe6ETk5GqfQqPJouLBwH6aagAnBYlmOsPdeK5+QhOP4DR SUQKfuvToF7SCt6sKMJW+Nb5+yeTns7U95CAfHJWEXsk0WhhB0D87tUA4quyqllrON5B W3tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p81-v6si1605321pfi.345.2018.08.02.02.42.59; Thu, 02 Aug 2018 02:43:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731192AbeHBLb4 (ORCPT + 99 others); Thu, 2 Aug 2018 07:31:56 -0400 Received: from 4.mo2.mail-out.ovh.net ([87.98.172.75]:36096 "EHLO 4.mo2.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726238AbeHBLbz (ORCPT ); Thu, 2 Aug 2018 07:31:55 -0400 Received: from player697.ha.ovh.net (unknown [10.109.143.216]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 9CDD514828F for ; Thu, 2 Aug 2018 11:23:12 +0200 (CEST) Received: from bahia.lan (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id 270354800CF; Thu, 2 Aug 2018 11:23:03 +0200 (CEST) Date: Thu, 2 Aug 2018 11:23:01 +0200 From: Greg Kurz To: Dominique Martinet Cc: v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Dominique Martinet , Matthew Wilcox , Jun Piao Subject: Re: [PATCH v2 1/2] net/9p: embed fcall in req to round down buffer allocs Message-ID: <20180802112301.6b581f1c@bahia.lan> In-Reply-To: <1533177452-2165-1-git-send-email-asmadeus@codewreck.org> References: <1532943263-24378-1-git-send-email-asmadeus@codewreck.org> <1533177452-2165-1-git-send-email-asmadeus@codewreck.org> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 14807835577272670464 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtiedrleeggdduhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 Aug 2018 04:37:31 +0200 Dominique Martinet wrote: > From: Dominique Martinet > > 'msize' is often a power of two, or at least page-aligned, so avoiding > an overhead of two dozen bytes for each allocation will help the > allocator do its work and reduce memory fragmentation. > > Suggested-by: Matthew Wilcox > Signed-off-by: Dominique Martinet > Cc: Matthew Wilcox > Cc: Greg Kurz > Cc: Jun Piao > --- > > v2: > - Add extra label to not free uninitialized memory on alloc failure > - Rename p9_fcall_alloc to 9p_fcall_init > - Add a p9_fcall_fini function to echo to init > [...] > diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c > index 2ab4574183c9..c5cac97df7f7 100644 > --- a/net/9p/trans_rdma.c > +++ b/net/9p/trans_rdma.c > @@ -122,7 +122,7 @@ struct p9_rdma_context { > dma_addr_t busa; > union { > struct p9_req_t *req; > - struct p9_fcall *rc; > + struct p9_fcall rc; > }; > }; > > @@ -320,8 +320,8 @@ recv_done(struct ib_cq *cq, struct ib_wc *wc) > if (wc->status != IB_WC_SUCCESS) > goto err_out; > > - c->rc->size = wc->byte_len; > - err = p9_parse_header(c->rc, NULL, NULL, &tag, 1); > + c->rc.size = wc->byte_len; > + err = p9_parse_header(&c->rc, NULL, NULL, &tag, 1); > if (err) > goto err_out; > > @@ -331,12 +331,13 @@ recv_done(struct ib_cq *cq, struct ib_wc *wc) > > /* Check that we have not yet received a reply for this request. > */ > - if (unlikely(req->rc)) { > + if (unlikely(req->rc.sdata)) { > pr_err("Duplicate reply for request %d", tag); > goto err_out; > } > > - req->rc = c->rc; > + req->rc.size = c->rc.size; > + req->rc.sdata = c->rc.sdata; > p9_client_cb(client, req, REQ_STATUS_RCVD); > > out: > @@ -361,7 +362,7 @@ send_done(struct ib_cq *cq, struct ib_wc *wc) > container_of(wc->wr_cqe, struct p9_rdma_context, cqe); > > ib_dma_unmap_single(rdma->cm_id->device, > - c->busa, c->req->tc->size, > + c->busa, c->req->tc.size, > DMA_TO_DEVICE); > up(&rdma->sq_sem); > kfree(c); > @@ -401,7 +402,7 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c) > struct ib_sge sge; > > c->busa = ib_dma_map_single(rdma->cm_id->device, > - c->rc->sdata, client->msize, > + c->rc.sdata, client->msize, > DMA_FROM_DEVICE); > if (ib_dma_mapping_error(rdma->cm_id->device, c->busa)) > goto error; > @@ -443,9 +444,9 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) > **/ > if (unlikely(atomic_read(&rdma->excess_rc) > 0)) { > if ((atomic_sub_return(1, &rdma->excess_rc) >= 0)) { > - /* Got one ! */ > - kfree(req->rc); > - req->rc = NULL; > + /* Got one! */ > + kfree(req->rc.sdata); Shouldn't this be p9_fcall_fini(&req->rc) ? The rest looks good, so, with that fixed, you can add: Reviewed-by: Greg Kurz > + req->rc.sdata = NULL; > goto dont_need_post_recv; > } else { > /* We raced and lost. */