From patchwork Thu Feb 7 12:22:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 2110431 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 680C03FDF1 for ; Thu, 7 Feb 2013 12:23:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758403Ab3BGMXA (ORCPT ); Thu, 7 Feb 2013 07:23:00 -0500 Received: from mail-ve0-f181.google.com ([209.85.128.181]:39456 "EHLO mail-ve0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758351Ab3BGMW4 (ORCPT ); Thu, 7 Feb 2013 07:22:56 -0500 Received: by mail-ve0-f181.google.com with SMTP id d10so2223480vea.12 for ; Thu, 07 Feb 2013 04:22:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=9K7ZNbfFwNtwDEQBd16XlPyJCbxaim+LpTNhDOsWOJY=; b=b9xgqyALykIQ9EyRhX6ZMtLjVFJTNeUQmOLLmkpR9YbkZ9U7M3wXWP+nW5fyXvFqnY /byaNkD0WX7nJwrjjPJSXx/VEjKjGI+A9JcpRLw0BDrVKbmZak5rAOdq9UAsdefSTygC UJgTJGnLS0TBr8Vb+Rd9J5isQn+apAIWBHkwjqDxyni3OeGAo4DO2nN6bHVutyNS2Zq9 JPDuFqWugQxS+ANey4AFQ0SOhvYM/GOkyPcv/R4PtM1XarQkY+syb2CU0OkHqBZr4rqd FNX+rZxjr3+nxLClnNMnm2hIIl0Dz9BJqn3Gh0QWWy2WZbH52jim6mtjK5RF7C2o8jle 4xlQ== X-Received: by 10.58.50.7 with SMTP id y7mr1336886ven.24.1360239775366; Thu, 07 Feb 2013 04:22:55 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id sk8sm37937888vdb.13.2013.02.07.04.22.52 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 Feb 2013 04:22:54 -0800 (PST) From: Paolo Bonzini To: linux-kernel@vger.kernel.org Cc: Wanlong Gao , asias@redhat.com, Rusty Russell , mst@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Jens Axboe Subject: [RFC PATCH 5/8] scatterlist: introduce sg_unmark_end Date: Thu, 7 Feb 2013 13:22:29 +0100 Message-Id: <1360239752-2470-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1360239752-2470-1-git-send-email-pbonzini@redhat.com> References: <1360239752-2470-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This is useful in places that recycle the same scatterlist multiple times, and do not want to incur the cost of sg_init_table every time in hot paths. Cc: Jens Axboe Signed-off-by: Paolo Bonzini Acked-by: Jens Axboe --- Jens, could you give your Acked-by for this patch? block/blk-integrity.c | 2 +- block/blk-merge.c | 2 +- include/linux/scatterlist.h | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index da2a818..0f5004f 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -110,7 +110,7 @@ new_segment: if (!sg) sg = sglist; else { - sg->page_link &= ~0x02; + sg_unmark_end(sg); sg = sg_next(sg); } diff --git a/block/blk-merge.c b/block/blk-merge.c index 936a110..5f24482 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -143,7 +143,7 @@ new_segment: * termination bit to avoid doing a full * sg_init_table() in drivers for each command. */ - (*sg)->page_link &= ~0x02; + sg_unmark_end(*sg); *sg = sg_next(*sg); } diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 4bd6c06..9b83784 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -172,6 +172,22 @@ static inline void sg_mark_end(struct scatterlist *sg) } /** + * sg_unmark_end - Undo setting the end of the scatterlist + * @sg: SG entryScatterlist + * + * Description: + * Removes the termination marker from the given entry of the scatterlist. + * + **/ +static inline void sg_unmark_end(struct scatterlist *sg) +{ +#ifdef CONFIG_DEBUG_SG + BUG_ON(sg->sg_magic != SG_MAGIC); +#endif + sg->page_link &= ~0x02; +} + +/** * sg_phys - Return physical address of an sg entry * @sg: SG entry *