From patchwork Wed Oct 10 12:53:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10634523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6335715E2 for ; Wed, 10 Oct 2018 12:53:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 154C328FB6 for ; Wed, 10 Oct 2018 12:53:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0378428F90; Wed, 10 Oct 2018 12:53:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8BDA28F90 for ; Wed, 10 Oct 2018 12:53:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC5DD6B000D; Wed, 10 Oct 2018 08:53:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C76666B0269; Wed, 10 Oct 2018 08:53:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B661A6B026F; Wed, 10 Oct 2018 08:53:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 717A16B000D for ; Wed, 10 Oct 2018 08:53:41 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id 87-v6so4344716pfq.8 for ; Wed, 10 Oct 2018 05:53:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=dEKcjPsEeJCNe3xmiMXLwcwsYW1yYuzLtfoWU3WTTio=; b=TOp2mkvBh07o9D27CjFUH1ub9BnyCFzkKo9HurTohkeXDVejdSE7yWKV5h+Qn3t4Pe /hYh8beS9zWXnf5slVX/6qtm4n+t+jRtyJjYcoSx4hpBxKrQv6vQfMfo+67UdyHA1kIL mhI03b/V4+u2IzIG/KcV6NPEYY5u8V106G3eNIWx4+wQVSmF/e3wUCuTNdD6KkRGLLBy GZRcgxZ6VOyRRheZLzEbWpYpEFoSbZNwBOImFbrgVKGD0hi4GGr7R8OxJcA0wEclHhCs dg771/41ArgPSF2gVC8SBIwfsshxVcRKnD3NuIJYLLj16ZGCiAQSGFMS01ocjzRNETkY EVaw== X-Gm-Message-State: ABuFfoghbFZ8g1vDeb4Lk3bhW7Lv7a56zuk9MK3uiKFmBQjzfnp4kdcP Kbm4QzQGLfjP0n3vPLGGqpn1IM3IA7o+fIzskTmRS4P/yhqJLLfWi45BolyatDc5I2GXEYiNE+N zx9QyY5WFl0rhq4CLT+UkuCC24Zyeqnz+SIjN7fuYNleRKzsUJgjI0lulkoYWOhQHHm3/A9WhpA 15dNb9PLPf7fIJttM4XZpTClIP8sEGE7DKqxhvpldbu6F3GIvZfZMiaybM/yTlV+bLz4ZtzywEb B2Q8hzjMu8BQLYTY/T9aSXffnPOxOBO6iPioDbDIMTJKn7xzqIZqOr+TIHdPvAP3/LmqPW2Z/Iq 9tFX3CejpV9AvcEqH+RmciypOQZxvCOIeNpCjSxF8JQ7PKdyC+sVHPMKo7qwp59mDU66FEgHzMv 4 X-Received: by 2002:a62:d40d:: with SMTP id a13-v6mr35449404pfh.23.1539176021147; Wed, 10 Oct 2018 05:53:41 -0700 (PDT) X-Received: by 2002:a62:d40d:: with SMTP id a13-v6mr35449365pfh.23.1539176020380; Wed, 10 Oct 2018 05:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539176020; cv=none; d=google.com; s=arc-20160816; b=LHNLmXQton6hwMLQYVjS7gsfIK422QbbIyornVZy+qgS0KcehUnqpJx5sCqEQPygTq 2JvIvHlpCbp/aGf7bUQOd+RF73ZxS4iZEkoavC+t2bDU5KYOzkONWcA309EnimgvMhYT UJX90GiI+5HjduBFK/5Oe06G2Xsy0sdooAiQ0KeO+AePI07p01kPMUkOgUhghhEQLnc4 ONZmOxbPHaVs00S8YTiVyK2lelwDGI53MHOdrkmqX2FwI+Suy+bv10ayxYxJnJc1IEqS UPjs2lFGs+mMtrP5CdQPoEetHfw3EqGFesBGBlAfuRv9dxiB3tR+Qch9Tm9OPY6o986T GRPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=dEKcjPsEeJCNe3xmiMXLwcwsYW1yYuzLtfoWU3WTTio=; b=qw2xKBsUW7B4WlCor1YZY1SJABTkPIlXl9Bilm9UPTSNjhnFOVB6UwXS8n1r2eXKkM GguKNpKgTXayHyAgeIyGLZxqufxPwV8pnv/pzfiuIK4xxt7MR+FvDG07BUrDUzqGsMWf 398v2IQJT83hXrOBGL4gk8z/0eaCa+IYH78Ch1lvl4OuQ4M2/HdENLArpqj+b8fhrTdA KqPoFSL+mZWYy8TKdazqAyuCe0z3wdYOY8ob9TPFctREbXTGu7hUlGyAhzmNV4Jg3GAe GiRJl7h/K/tvxaIrY+q9SlA5P+MQ2cwPTCJ/EL/7uWT1LtBVs3joO3+gMNr2EM0NUT1j 6mLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=buO8pga1; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w11-v6sor20337116pfk.56.2018.10.10.05.53.40 for (Google Transport Security); Wed, 10 Oct 2018 05:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=buO8pga1; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dEKcjPsEeJCNe3xmiMXLwcwsYW1yYuzLtfoWU3WTTio=; b=buO8pga1xiDb/gfp1dZFVqxLTSKmbwJnTY3f1NlOSMTawl849XkDmSyrfxhmsNZt8F LOMEGhFe8BXbZf/toSttyoNKCmqduzMRDZSpo0rGUjKbCzQa9iKHy8DmHBMG2ohUKg7w cMUJ/AtQzO5B20K6JcK+xLfiq5Ek8+xcSYs6cmfuqeQyIAUAF2XVo9UXRKQNQVcerU1i I6nhjaEPXfw3U5fGgVYAfHCPsygLB4luLqo3jzkxqaGpu6C2J4J+tWy5FOv5ptMP8sLp SbkoiJ3p/bXBiXgAx1zFtUYlFO+uvgJpNXLtHEwFm6i+9zmRpNtIMkEQBNYWJk+t0hok 41hA== X-Google-Smtp-Source: ACcGV61cuK5Al/d3k50/xXFzbzSQHRe8M5FBJemPaX48/YzdmDNJHeSJWldmmNuXVzFybeUFmuuajg== X-Received: by 2002:a62:1c06:: with SMTP id c6-v6mr35162333pfc.41.1539176019802; Wed, 10 Oct 2018 05:53:39 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id p24-v6sm25903430pgm.70.2018.10.10.05.53.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 05:53:39 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, mhocko@suse.com Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH] mm: remove a redundant check in do_munmap() Date: Wed, 10 Oct 2018 20:53:27 +0800 Message-Id: <20181010125327.68803-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 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: X-Virus-Scanned: ClamAV using ClamSMTP A non-NULL vma returned from find_vma() implies: vma->vm_start <= start Since len != 0, the following condition always hods: vma->vm_start < start + len = end This means the if check would never be true. This patch removes this redundant check and fix two typo in comment. Signed-off-by: Wei Yang --- mm/mmap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 8d6449e74431..94660ddfa2c1 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -414,7 +414,7 @@ static void vma_gap_update(struct vm_area_struct *vma) { /* * As it turns out, RB_DECLARE_CALLBACKS() already created a callback - * function that does exacltly what we want. + * function that does exactly what we want. */ vma_gap_callbacks_propagate(&vma->vm_rb, NULL); } @@ -1621,7 +1621,7 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg) #endif /* __ARCH_WANT_SYS_OLD_MMAP */ /* - * Some shared mappigns will want the pages marked read-only + * Some shared mappings will want the pages marked read-only * to track write events. If so, we'll downgrade vm_page_prot * to the private version (using protection_map[] without the * VM_SHARED bit). @@ -2705,12 +2705,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len, if (!vma) return 0; prev = vma->vm_prev; - /* we have start < vma->vm_end */ - - /* if it doesn't overlap, we have nothing.. */ + /* we have vma->vm_start <= start < vma->vm_end */ end = start + len; - if (vma->vm_start >= end) - return 0; /* * If we need to split any vma, do it now to save pain later.