Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2308340pxp; Mon, 21 Mar 2022 16:31:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJahHClXGI2lqhujFMAtEnW9OUES7LLTgSreJ6+gw1xc61XCBzbNo3UDrA2cpWrE5EFCUl X-Received: by 2002:a63:2004:0:b0:375:ed63:ab4c with SMTP id g4-20020a632004000000b00375ed63ab4cmr19877875pgg.255.1647905493526; Mon, 21 Mar 2022 16:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647905493; cv=none; d=google.com; s=arc-20160816; b=At9dum+I2bLjnzXcVqGHqMA6mtO8axX4qw2sTmkZzLaCc2RfBDxaz0WzovfCmq2DAo vZJbjYpu3HjIN5hVKULIlV39NHXWsWyrJFzuaWhK7532Ag9usanVAVgRTcHmmlKIkBhr gZ24H53l2xau5VbiqNu/0sOEBQbtAqJjlCHUk6fG/BtjVC3lBCJ6BkRNS16CyjznOEIF eXK+FQLZWhb+9DFmfqR+ZZ1YNnA6FEH5+iA+y5HRBL169jucTRxvCU3xklSDwDbze/zB /xdh9wUCKs0c8Y1cD683qDrBD0CAI8y5YEcc2cgtCQFg4aRp+qx+Ewf3SnIBPrcfo6+Q SRaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MEC5W64mg/dChPmSON3+rx/2O3+zfOyzeqWukrfjHaE=; b=aU30c6nmAvbY7tK4gbWDjF/4qy9HP8U70OX9hWujiR8k/crO+oZ6spH60kF348eA/j hu6Cz9VYoggPcW37EAg5rRC6ev0DrSv6G9zB8yM3lMwIFZ5acreIqAA1hNBfBtXeg0cu cmeCcHsfkoIQrxY7r/pjATxDf/1g3v7FKDRqwhk0Gxp1Fo4IR2OhFRE1eaMhsc39z11m psyWs92UhSfNQ4GcdezQknEWn8t9yHMjrWlNwMLrcWUVq5ft7u5UqtEpdzwujDz6SU8V HsRKIKgdDVVqu836SXc7z8hZ3o+V5j6vuJjL0wkX3qDxrkhnovoK6gcPMkcIxfFaD73w KwPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UhK0TEdF; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v5-20020a63f845000000b003816043ee86si13645626pgj.123.2022.03.21.16.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:31:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UhK0TEdF; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64E3738DD37; Mon, 21 Mar 2022 15:22:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240904AbiCUD41 (ORCPT + 99 others); Sun, 20 Mar 2022 23:56:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiCUD4Z (ORCPT ); Sun, 20 Mar 2022 23:56:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F21FE13EB6 for ; Sun, 20 Mar 2022 20:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647834899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MEC5W64mg/dChPmSON3+rx/2O3+zfOyzeqWukrfjHaE=; b=UhK0TEdFoY19+49qHdVGXN0WVXurJPqOOIWy6eahW6Qq4zVZNQr0NcrF7L66/sr+Kxq5Np Kbl5jj1fF4r07XCuuLVb5N4f3OWWlD7HL9XedAWYF05gP0EVIdQ2OIpsZoBo/ohlwsJAkO heUwlfBvHdh6sxDxbS3MjZ6nWOVSzQs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-d0wMJBzJPc23XLU06H5n6Q-1; Sun, 20 Mar 2022 23:54:55 -0400 X-MC-Unique: d0wMJBzJPc23XLU06H5n6Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50332802C16; Mon, 21 Mar 2022 03:54:55 +0000 (UTC) Received: from localhost (ovpn-12-54.pek2.redhat.com [10.72.12.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B9E02166B2D; Mon, 21 Mar 2022 03:54:53 +0000 (UTC) Date: Mon, 21 Mar 2022 11:54:50 +0800 From: 'Baoquan He' To: David Laight Cc: "linux-kernel@vger.kernel.org" , "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() Message-ID: References: <20220318093706.161534-1-bhe@redhat.com> <20220318093706.161534-5-bhe@redhat.com> <1592a861bd9e46e5adf1431ad6bbd25c@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1592a861bd9e46e5adf1431ad6bbd25c@AcuMS.aculab.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 Hi David, On 03/18/22 at 01:48pm, David Laight wrote: > 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 ... Thanks for reviewing and looking into this. People may have the same feeling as you when looking at codes at the first glance. While usually we all use editor to explore codes, so. Basically, I noticed putting open code into wrapper is a tendency, see a lot of patches to clean up open code in sub component. About the extra cost of wrapper, I believe it does have. It should be one of reasons in some places open code is necessary. However, in fs/proc/vmcore, I don't have the worry since it's very tiny and can be ignorable. Thanks Baoquan