Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2568332pxp; Fri, 18 Mar 2022 13:27:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+7SuudHAfwUUZ892x4onn7vm7TSReX4n46la1HloS0TmeoflzsWtQOidFRxzaqntvWZwl X-Received: by 2002:a05:6a00:22c1:b0:4f7:3e72:d99b with SMTP id f1-20020a056a0022c100b004f73e72d99bmr11988896pfj.79.1647635275453; Fri, 18 Mar 2022 13:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647635275; cv=none; d=google.com; s=arc-20160816; b=NlMhuw35f3pYsLdC/l2MOM4w8WVCcXM0lGti28OEojOA+X6ZDC7z9DUqEE8/NKhXM/ O5VMXok7j+QxUKwqiJa7ssp4nGyUlri0R3QRkyIXyTdZHKTvA05u2IBw90sXzsLhLov/ 99SL/8tK4A9OUwWrsnydkqBQMPHOzG6fm0iuZfbYb+C5IQIQ9X+OkNGPgHH5Bx2hHbo5 T9rWt08v4oTK0jGPb42DwX7+A0VFDQoxaQepUganH/YJSls/UcZ9iDXBlScxV7b5lasb NNf4jFIuJXdVhGnYVzGGMvgETZ1mDB13urq6lv6n+XKaaQ2fmoXjlVR8ezcROakD4OJr FFyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=4fxO4QZ8HnN/PwibiTstxi8zcdANIlYTVHyPIcY7qP4=; b=xLAof55YiyuImcu9K6D6SXTGZrdCRnrZ5hw6mGiYs5hg8geafdQZAqpRFwqNYzgyfW v57rj1uud7JsLjSRGRlxwQw5tyHwOJS9xWfFjQKC5gRMmSWeNaKzcaac0IGpM1TqZDoM Tg4WgHCBM3RhKjmgBIJLJk7Y2Nr1iYkyYVM221RWHtpE1lsEMd8QL5LhSb0WtQlU1Pp3 EZYOuDvzWe39J9Ut0viR4Z+wFr5NBEGMdr0ntIaKcvgUBUMfKRK4yT3yqbZQ3bwFNObE Rb7IuwNEhmE8hMg5Tl1RN4XxEuWxiBUNgCnDA82dp6Swu/O+K3bLgmmtnLGV+6b7OsH+ JRsg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020a170902c3c100b00153ff064711si2818447plj.144.2022.03.18.13.27.42; Fri, 18 Mar 2022 13:27:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236824AbiCRNtd convert rfc822-to-8bit (ORCPT + 99 others); Fri, 18 Mar 2022 09:49:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236819AbiCRNtb (ORCPT ); Fri, 18 Mar 2022 09:49:31 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A6D792DCB for ; Fri, 18 Mar 2022 06:48:11 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-230-7BPTG6E3OgCK3NW-RJ4mhA-1; Fri, 18 Mar 2022 13:48:08 +0000 X-MC-Unique: 7BPTG6E3OgCK3NW-RJ4mhA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 18 Mar 2022 13:48:07 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.033; Fri, 18 Mar 2022 13:48:07 +0000 From: David Laight To: 'Baoquan He' , "linux-kernel@vger.kernel.org" CC: "willy@infradead.org" , "kexec@lists.infradead.org" , "yangtiezhu@loongson.cn" , "amit.kachhap@arm.com" , "hch@lst.de" , "linux-fsdevel@vger.kernel.org" , "viro@zeniv.linux.org.uk" Subject: RE: [PATCH v4 4/4] fs/proc/vmcore: Use iov_iter_count() Thread-Topic: [PATCH v4 4/4] fs/proc/vmcore: Use iov_iter_count() Thread-Index: AQHYOqvdJiWddWfO9ESrhwkm/5kbyKzFJutw Date: Fri, 18 Mar 2022 13:48:07 +0000 Message-ID: <1592a861bd9e46e5adf1431ad6bbd25c@AcuMS.aculab.com> References: <20220318093706.161534-1-bhe@redhat.com> <20220318093706.161534-5-bhe@redhat.com> In-Reply-To: <20220318093706.161534-5-bhe@redhat.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Baoquan He > Sent: 18 March 2022 09:37 > > To replace open coded iter->count. This makes code cleaner. ... > diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c > index 4cbb8db7c507..ed58a7edc821 100644 > --- a/fs/proc/vmcore.c > +++ b/fs/proc/vmcore.c > @@ -319,21 +319,21 @@ static ssize_t __read_vmcore(struct iov_iter *iter, loff_t *fpos) > u64 start; > struct vmcore *m = NULL; > > - if (iter->count == 0 || *fpos >= vmcore_size) > + if (!iov_iter_count(iter) || *fpos >= vmcore_size) For some definition of 'cleaner' :-) iter->count is clearly a simple, cheap structure member lookup. OTOH iov_iter_count(iter) might be an expensive traversal of the vector (or worse). So a quick read of the code by someone who isn't an expert in the iov functions leaves them wondering what is going on or having to spend time locating the definition ... David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)