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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 629CAC31E45 for ; Thu, 13 Jun 2019 16:02:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BF1320679 for ; Thu, 13 Jun 2019 16:02:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729267AbfFMQCz (ORCPT ); Thu, 13 Jun 2019 12:02:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34798 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387749AbfFMQCx (ORCPT ); Thu, 13 Jun 2019 12:02:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7505B2DD4; Thu, 13 Jun 2019 16:02:53 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9742B5427C; Thu, 13 Jun 2019 16:02:52 +0000 (UTC) Date: Thu, 13 Jun 2019 18:02:49 +0200 From: Cornelia Huck To: Eric Farman Cc: Farhan Ali , Halil Pasic , linux-s390@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v2 6/9] vfio-ccw: Adjust the first IDAW outside of the nested loops Message-ID: <20190613180249.1f26258d.cohuck@redhat.com> In-Reply-To: <20190606202831.44135-7-farman@linux.ibm.com> References: <20190606202831.44135-1-farman@linux.ibm.com> <20190606202831.44135-7-farman@linux.ibm.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 13 Jun 2019 16:02:53 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, 6 Jun 2019 22:28:28 +0200 Eric Farman wrote: > Now that pfn_array_table[] is always an array of 1, it seems silly to > check for the very first entry in an array in the middle of two nested > loops, since we know it'll only ever happen once. > > Let's move this outside the loops to simplify things, even though > the "k" variable is still necessary. > > Signed-off-by: Eric Farman > --- > drivers/s390/cio/vfio_ccw_cp.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c > index 86a0e76ef2b5..ab9f8f0d1b44 100644 > --- a/drivers/s390/cio/vfio_ccw_cp.c > +++ b/drivers/s390/cio/vfio_ccw_cp.c > @@ -201,11 +201,12 @@ static inline void pfn_array_table_idal_create_words( > pa = pat->pat_pa + i; > for (j = 0; j < pa->pa_nr; j++) { > idaws[k] = pa->pa_pfn[j] << PAGE_SHIFT; > - if (k == 0) > - idaws[k] += pa->pa_iova & (PAGE_SIZE - 1); > k++; > } > } > + > + /* Adjust the first IDAW, since it may not start on a page boundary */ > + idaws[0] += pat->pat_pa->pa_iova & (PAGE_SIZE - 1); > } > > Also +1 to adding a nice explaining comment :) Reviewed-by: Cornelia Huck