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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 B0875ECE59D for ; Wed, 16 Oct 2019 05:50:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 641842168B for ; Wed, 16 Oct 2019 05:50:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aWNfRx80" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 641842168B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D06F08E0006; Wed, 16 Oct 2019 01:50:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB80D8E0001; Wed, 16 Oct 2019 01:50:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA6E98E0006; Wed, 16 Oct 2019 01:50:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id 9BD9F8E0001 for ; Wed, 16 Oct 2019 01:50:13 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 4F4D0180AE81E for ; Wed, 16 Oct 2019 05:50:13 +0000 (UTC) X-FDA: 76048572306.19.blood90_1dc6144e874a X-HE-Tag: blood90_1dc6144e874a X-Filterd-Recvd-Size: 6934 Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Oct 2019 05:50:12 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id a1so52272789ioc.6 for ; Tue, 15 Oct 2019 22:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2iVaiLEeBiUmrTL+aXVn2d1xOQF7wGfeU6G6/ubdpB8=; b=aWNfRx80e3jGp0SNb4hDW6ZOaJSVh+9J2tcgd5Nif+wjXNOV5swgTpEAsGHcKKovAU nSR1CKbTbEQFeERVtGp7DLvce5K25mx4eOA4cFWY/KRRuugo9BwuOSXloousGAxgw2cR kkjm7lOwDk/3UzYDD7IAwrqfjhOzggRvFt7cxuozUts8z1wUAgQ4AlhKLq5WrbubovyN ZvxPw3ZnVILnGmduuL6v+DqKAzMtUoyLzB5zzt4PunzozYJLe3aPBjtOxveNL0rDrpTL O15UtL6XEbUS/jbqHilbG/DpTSiTWEuCilU89mqY1CUex+2EzLIUJCVnw6mrDJ4XOmju 2v/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2iVaiLEeBiUmrTL+aXVn2d1xOQF7wGfeU6G6/ubdpB8=; b=lontQoYF5kxkrynHLbQKEXhjtzlVgsxCZcr6oZzZ9LiXM3rB92VNoSTdq2KVgf6rzS Dioy0lNJzpDcB5vbRaFdTO7TRUMdGAKCL2OJGjvLEqd8bhT+OvMFDcN/dlsWLTTpCpR0 TwRJHLKAk2JwYElBj+aLwjRzt6+V5Bg38JDfa6VxcFcknUPMfvux5txeDfAcKZB2pxrV yoOzmlUmxx5sxhjZRSYqwnVUAX/EV71ET0ykeWSanNJcjUCVp0gIZX3BtiUBgZANCyY/ 3/75l6PGJCVorf2ioy79ufZMCKkFltxaskvoVMfZ7xaLWLDxvmU9J4HFcvC+WuUHiuNL 1GVQ== X-Gm-Message-State: APjAAAUWlvdL7Jldj00IBT7r0vdMwg/Ub1q8FqbdDh0gJRxHg2ArKwT/ XR/n1kKmrhDkP5TgtWVfvYSnEYiAk02msyTrlQE= X-Google-Smtp-Source: APXvYqz5oq+Q/6BIy1vxvMnlmvZgY+bF0jJVSZFnq33+QovpDdYxd18LzaDzFxQ5db8e9dfVYOk0h8UxokxzaTp/SWk= X-Received: by 2002:a6b:6a0e:: with SMTP id x14mr2125167iog.150.1571205012053; Tue, 15 Oct 2019 22:50:12 -0700 (PDT) MIME-Version: 1.0 References: <20191012102512.28051-1-pugaowei@gmail.com> <20191015123301.GC24932@dhcp22.suse.cz> In-Reply-To: <20191015123301.GC24932@dhcp22.suse.cz> From: gaowei Pu Date: Wed, 16 Oct 2019 13:50:01 +0800 Message-ID: Subject: Re: [PATCH v2] mm/mmap.c: use IS_ERR_VALUE to check return value of get_unmapped_area To: Michal Hocko Cc: Andrew Morton , Vlastimil Babka , linux-mm@kvack.org Content-Type: multipart/alternative; boundary="0000000000009ce12a059500ac31" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --0000000000009ce12a059500ac31 Content-Type: text/plain; charset="UTF-8" On Tue, Oct 15, 2019 at 8:33 PM Michal Hocko wrote: > On Sat 12-10-19 18:25:12, Gaowei Pu wrote: > > get_unmapped_area already cover the offset_in_page() check and returned > > with error ptr. So replace offset_in_page() with IS_ERR_VALUE(). > > I have to say that I found offset_in_page check quite unintuitive. It is > a relict from the past I suspect. A newer code seems to use > IS_ERR_VALUE. If we want to make the code consistent then I am for it. > Could you check other users as well? git grep suggests checking > kernel/events/uprobes.c, mm/mmap.c and mm/mremap.c. > I only noticed the offset_in_page check after returned from get_unmapped_area is redundant. So I just replace the places where get_unmapped_area returned. As you mentioned, IS_ERR_VALUE maybe the newer code to check the error ptr compared to offset_in_page which is really unintuitive and therefore I will replace them in mm/mmap.c and mm/mremap.c. > I would simply use the following for the changelog > " > get_unmapped_area returns an address or -errno on failure. Historically > we have checked for the failure by offset_in_page() which is correct but > quite hard to read. Newer code started using IS_ERR_VALUE which is much > easier to read. Convert remaining users of offset_in_page as well. > > This shouldn't introduce any functional changes. > " > > OK, I will use your changelog and resend a patch. Thanks. > > > 2.23.0 > > > > -- > Michal Hocko > SUSE Labs > --0000000000009ce12a059500ac31 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Oct 15, 2019 at 8:33 PM Micha= l Hocko <mhocko@suse.com> wrot= e:
On Sat 12-10-= 19 18:25:12, Gaowei Pu wrote:
> get_unmapped_area already cover the offset_in_page() check and returne= d
> with error ptr. So replace offset_in_page() with IS_ERR_VALUE().

I have to say that I found offset_in_page check quite unintuitive. It is a relict from the past I suspect. A newer code seems to use
IS_ERR_VALUE. If we want to make the code consistent then I am for it.
Could you check other users as well? git grep suggests checking
kernel/events/uprobes.c, mm/mmap.c and mm/mremap.c.
I only noticed the offset_in_page check after returned fr= om get_unmapped_area is redundant.
So I just replace the places where get_unmapped_area returned.=C2=A0As you mentioned, IS_ERR_V= ALUE maybe
the newer code to check the error ptr compared to offset_in_page = which is really unintuitive and therefore I will
replace them in mm/mma= p.c and mm/mremap.c.
I would simply use the following for the changelog
"
get_unmapped_area returns an address or -errno on failure. Historically
we have checked for the failure by offset_in_page() which is correct but quite hard to read. Newer code started using IS_ERR_VALUE which is much
easier to read. Convert remaining users of offset_in_page as well.

This shouldn't introduce any functional changes.
"

OK, I will use your changelog and resend a patch. Tha= nks.

> 2.23.0
>

--
Michal Hocko
SUSE Labs
--0000000000009ce12a059500ac31--