From patchwork Sun Oct 28 06:13:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 10658473 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 5B6E7161F for ; Sun, 28 Oct 2018 06:14:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AA0E2A466 for ; Sun, 28 Oct 2018 06:14:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EBED2A46E; Sun, 28 Oct 2018 06:14:06 +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 C1DDF2A466 for ; Sun, 28 Oct 2018 06:14:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C6FD6B0342; Sun, 28 Oct 2018 02:14:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5760A6B0344; Sun, 28 Oct 2018 02:14:01 -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 43D436B0345; Sun, 28 Oct 2018 02:14:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 186E56B0342 for ; Sun, 28 Oct 2018 02:14:01 -0400 (EDT) Received: by mail-qk1-f200.google.com with SMTP id r125-v6so6359567qke.8 for ; Sat, 27 Oct 2018 23:14:01 -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=VhxQaZVeo56RaiB8wyhLO+qK877wT7vkbBj9B1knW1o=; b=dWC7wTlFRXNVGVASK/XCYU5wnP8E9bELzoPR8yY97Vzh/7Gk2tfJSMAu3FsC+ez6Eq nsRtpv+M5jqAvWsHUyWgY6wbtmaYnmP0VAGEW2Eb0TjzhXcVrR8I8uPMWeANtG3GcZni 38zY4gjfH6RfXgNlyB6DWpm4M6ooi8wWjJZjE1wg83KzrPWvVF5cY+iL0UbjWZ0qOZ1V 8GEgp3eMZfQi+pMeNJJyPdIAu0vXvTUwpk9sQWm+8PK0EpppcT1ivgP50BqlGMa9XnhQ fgdpUio5m9DxvKGANqDg/BaQI4u2ipdCuXOhVRkRTd5pRx7+g6lQ/ooWRxo3kTdU2XLd MJmw== X-Gm-Message-State: AGRZ1gLL4JMcYRkr+1ugFzwPMrSXtiQfqYXgNdT1v5sfMUAEERSwoayg KZMthMA6Fqu+oLWml6jskGwGP3uNqm1lG5H/1yZiK9FoduSmI54FRP5WHPZtutsm2ErQf+AFvg2 lL4L0SeeWRHYthKcVvixsKKEi+LY3sRB8X/ZqWh4cx4e2khiNz0I0EsxOTbloZrMk7Q== X-Received: by 2002:a0c:bd15:: with SMTP id m21mr9112681qvg.77.1540707240727; Sat, 27 Oct 2018 23:14:00 -0700 (PDT) X-Google-Smtp-Source: AJdET5e/0u9QJoIM4ZtsLfAmA0TbOmNPwFriIZRBZ+NggKzcOWgk8akAg/KWSeLZ98kkSw799yPV X-Received: by 2002:a0c:bd15:: with SMTP id m21mr9112654qvg.77.1540707239980; Sat, 27 Oct 2018 23:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540707239; cv=none; d=google.com; s=arc-20160816; b=SngeDlJZ4jhXquSOri7mCk7jlXwe+y7x+knNPFyxkWBV3Y0Wt/fllN3LtG+QJ1Q+Zz y5WY9hkgW+Jeiwwb4L2vC+ZGOFIEzv5s/jQz4IBIsntZNzI9Xft8ISqXHyWNddWfkuVZ 7ulfMxSm5RZRLrv/MeXmwYZo5VjX/jls9OB0g/ZSkFVXCGQjDvvHK46mtS2WIXPXlLdF fvlYni2+/SNd9Y7lkJ2NtP2NrrdRt0kpDgbQ5Zryp3q7Hglz+9a7U7R1j3r6AlVHKvwT MX3oI53twVSMyRYOMoW2UHp6R2BhFpj3Sgtr0ePTqKMu75qjQA1ZH5vajewS3tktRpbh lwLw== 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=VhxQaZVeo56RaiB8wyhLO+qK877wT7vkbBj9B1knW1o=; b=bDCzZDtLUtCBuJfKhAWLrXY0NDJG91+H7aswK7N37X49zMpeEBLkIKc9NbhJzBX8AQ 53kRxgfvTPwugBCa64XPtkw7IVnv3+bi2diq5b5Kc0aBnHLlFpNFeftsGojBpdpUGdBm KHi0/lRc/cAWlHxV0J35wFC16/34ckfV4impSnWJ6mAT2sUBMKqzKU6rjugdDTOpny7s /RCJXsESerXlIr9GTdb2jI7m+sl1G+dt/juW60d+Ek+C1GY6OTnKkwQwR8iefeD1s6sH WXsx5vsmdxLSmSvwFXoHoJh4dhHMNEJsSCTDYD5Jv6ltwj0h0OcfhsJK+xYoMYuYAtoj LFKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=EQqjk13c; spf=pass (google.com: domain of hsiangkao@aol.com designates 77.238.179.84 as permitted sender) smtp.mailfrom=hsiangkao@aol.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: from sonic309-26.consmr.mail.ir2.yahoo.com (sonic309-26.consmr.mail.ir2.yahoo.com. [77.238.179.84]) by mx.google.com with ESMTPS id f60si4590898qva.210.2018.10.27.23.13.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 23:13:59 -0700 (PDT) Received-SPF: pass (google.com: domain of hsiangkao@aol.com designates 77.238.179.84 as permitted sender) client-ip=77.238.179.84; Authentication-Results: mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=EQqjk13c; spf=pass (google.com: domain of hsiangkao@aol.com designates 77.238.179.84 as permitted sender) smtp.mailfrom=hsiangkao@aol.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1540707238; bh=VhxQaZVeo56RaiB8wyhLO+qK877wT7vkbBj9B1knW1o=; h=From:To:Cc:Subject:Date:From:Subject; b=EQqjk13cvjvftxTWPOA76Vgk35NxkjU5vhq4Y/neGnm5IrSRv6sgaWlJP57XOuOi4/B4qmaRnmS5N+VBfAPmee1xjkAlklR79s70K7OFMnCQ6sje/22wTa/Lk5R3eOLzqkGRBIZzRl+W6izlHBSw9UXwWM3nwLdKORAoB/ZmqvMAh9PNaFXLCwUgm0JnkXcwemUEhhXnSkksZFgLKxjLELnqqWE2hRuH0CWp7ThjUpd0j/0Z+fF3HuiFbBdmOYZoVrUz00rNHwStqq9w2Cl7YQehKu9Y9E027UGcVk19DC9gqSlPa2j/9t7rkEJf+JTJyr1KRAhIncv6j6erymDbpA== X-YMail-OSG: 1sf1u20VM1kzHYmcXk_ampsE0BbxDPD.j15Ay7eNV2uJzVImzuVZu.wgxf2SrAl rrEYTPbznokyVP3LWIj2VxvHPWkEc8tcRQsOhU6NLoBaLRM6OI.5Nt52b8aTA0rkmK8SLGqAe9Sp M2NykEp5PAiNa.bE_CA.JYlDwP1PJzDfnQ_BfmJAukXrb9rxVPwGyO7pDSfLZQLywKWA52IQEkFW OI4.4R3PycmRCtqA8oZKy6UvC6Ff1FgEiJqlkbJEsHaLISFRvcTqvOXMZvTUY_cFpD_CScd.572J oSXwdpkAffJpBAM4mXR_DuTHzIRMtSy8nEEvw0fzv3U7wfa.bMsdFWjBo36N5D6SDcPiyMefK8Ig xyNk4XWYGrcRAQW5qIQkdUJCv.JHE_nCa8h304dYcB5WuEAMjVGUJLvpd4XWUhAcK_rGEif60adM xmEz42evtYIAOMxX9ZOTJEEWcMsUOXkNcD9pixGqR4P9Z9MtsfxFKfWMszOfRwR0SGLfU7j.xdGi d4LSGJ2F1YE3KJmaZFuc53gKLGbp.1CW59f9rS.yjTdEsnReB.cCRTjtaF_HojAddO.mB70ZGos1 UTtbBNOPOLDSJmIO0EpmXQToxAZEzEG3TdVlUD0xzngfI1d0VJxCTsv5HzJb3I88Vex0kHDbUUYq MCwSomaUZSriVcYbgsQ9fzpdaX6GWXtBw_Pn5Dx7V7Q1z8lLVKgv9kPpr8BHZwjtyYG55r7JSW.P ZaHMwC6CvS8IvUkR5tr8yc.b9xQsUibbcHpR75XkxepBBQy9wYzlgrN_TfA9N1kgEDjtXy9K4pGx n9CWnAUF7r4OCPLgJxBqlhEhGMA9r3_Whaw_FMWV_7Aqm_0jnlomfyVFpTisQC4hMxX9jfKuOZMk b7L5CrPnALPUN2aFXRFbppjbM_smie8hYJxl9ZaqTmLOWUdxfz2Anw52bXCJ6tvR3ySBiIvzQz5Z 289GUggBq2M_pG9ycnuasnMQfMEtQ1uRM6IcmSj2JmTgr3j7vAYEgK.7mY.385cZQEpP8wtM_mOv LCq1rd0ZoBLtrzXu_egzU_ImmSaBRiUVTYytWwRPOYOgw3QPnf.c6 Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ir2.yahoo.com with HTTP; Sun, 28 Oct 2018 06:13:58 +0000 Received: from 115.192.33.5 (EHLO localhost.localdomain) ([115.192.33.5]) by smtp401.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID b5523328932f1292aff25b91619b79bc; Sun, 28 Oct 2018 06:13:56 +0000 (UTC) From: Gao Xiang To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Fengguang Wu , Gao Xiang Subject: [PATCH] mm: simplify get_next_ra_size Date: Sun, 28 Oct 2018 14:13:26 +0800 Message-Id: <1540707206-19649-1-git-send-email-hsiangkao@aol.com> X-Mailer: git-send-email 2.7.4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.020932, 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 It's a trivial simplification for get_next_ra_size and clear enough for humans to understand. It also fixes potential overflow if ra->size(< ra_pages) is too large. Cc: Fengguang Wu Signed-off-by: Gao Xiang Reviewed-by: Fengguang Wu Reviewed-by: Matthew Wilcox --- mm/readahead.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 4e63014..205ac34 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -272,17 +272,15 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) * return it as the new window size. */ static unsigned long get_next_ra_size(struct file_ra_state *ra, - unsigned long max) + unsigned long max) { unsigned long cur = ra->size; - unsigned long newsize; if (cur < max / 16) - newsize = 4 * cur; - else - newsize = 2 * cur; - - return min(newsize, max); + return 4 * cur; + if (cur <= max / 2) + return 2 * cur; + return max; } /*