From patchwork Wed May 30 06:12:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Thelen X-Patchwork-Id: 10437651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4A596602BF for ; Wed, 30 May 2018 06:12:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 397F128833 for ; Wed, 30 May 2018 06:12:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E61628867; Wed, 30 May 2018 06:12:25 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL 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 823E628833 for ; Wed, 30 May 2018 06:12:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D54B6B0007; Wed, 30 May 2018 02:12:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 483BB6B0008; Wed, 30 May 2018 02:12:23 -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 373C86B000A; Wed, 30 May 2018 02:12:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-vk0-f72.google.com (mail-vk0-f72.google.com [209.85.213.72]) by kanga.kvack.org (Postfix) with ESMTP id 02DB26B0007 for ; Wed, 30 May 2018 02:12:23 -0400 (EDT) Received: by mail-vk0-f72.google.com with SMTP id h62-v6so6958566vke.1 for ; Tue, 29 May 2018 23:12:22 -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:mime-version:date:in-reply-to :message-id:references:subject:from:to:cc; bh=fiV9iJcQjxqap98CwFkr5BPL8x33fS1+9534pZZSVtY=; b=C3xWB6gUS17D6nG+wI9UiUBQdUUbn6krVGREfRUbHn6Z5ubqW5HF8+c6gZnHObEE/M Z8rsYJC3v6wZGqJsDS63fz88E3wOIj2+vvvfad+YIrLqe4jQhZMxX1m3mRsHbYucia6g 0NPFewcixWcNRQ3rH13g6oAtzPHFIA39YWxO5AY7S4+sGaKkLDjLIpoxTATwXshod/1r 1mdnpEWRcayCzapxxoYZvLeAJ9Nuxv/rohxtTr4zTYBhKA1jvh4ce9heolFFRyooG4Qk 7hT5waWXkvH9K43RyhyOj3JS++TKRUD+O9J6D/5gBOJ46hh4wcwAZ20HgETK6UmF1U86 0lRA== X-Gm-Message-State: ALKqPwdfU5ufqhA1Uz58jPDnozL92CqwMYsXP8C7NBhVO+/F+GfkT0UN Bnbdf6LZs/xsSeFus7PpwYZCQMlZOn/fZYSbYXidjvmH7NoQ8JEUiAWLEs6+mZu3uZ24MqOyXOE lL6UEHPrBM3UMxJsCXyBA/2t7/ppsmn/LWxp/GCUPlUsAYjVeH3DyGUv/pcrRS0b6OrC5LoCzO9 QxVAmH1xJrmStThsKLhi4pKdIdP9IXCsSZQB2wttfzoX2OwZZQt809gPmZ6aPa0AQb9AHZIzYRT yjZ8HSB8SynW98lNa3nZYOr3rRFvsz8fGLcmW7AwHmd74amHLXVlUXqBXEB8x4fWA2JwBOIaAuI I4ahCy81vIXlDH0YWFLpen7ZdQ4jJwlzxBAGVMnCo/meqI+d9v881OJrmQqcVNVgm8N2PNXmSEM 2 X-Received: by 2002:ab0:5543:: with SMTP id u3-v6mr790635uaa.91.1527660742621; Tue, 29 May 2018 23:12:22 -0700 (PDT) X-Received: by 2002:ab0:5543:: with SMTP id u3-v6mr790619uaa.91.1527660742017; Tue, 29 May 2018 23:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527660742; cv=none; d=google.com; s=arc-20160816; b=NH9wzBfOMadMUV7hqBQSN3IwM8TtmwQKzsq3TlgE83lZZah14beunflctAuhJedWcZ 7ZETOvgR1xeshs83FrwtVG+esZghtB2wBA4KE/C5DJzGY+Vu416QVfeuMWY3YeQNiITY 3wLDKtZ9ThpoZTq6Hs3KemLXtolDwXMkEdU3oSldNP4SSQLMK/SSJjilwi4JdhwPhz1I WjvW0c6nfh38CObOojMc2P6LRFxqcTRtkWHsVFEkyJqMvncNlk233bp+tPH19klZZl4m OZeBG/im5dJV1h/Q5l83tDKxgr9bXdGYLBayacznTx//RSkufEmOq9g9y6GhHuP5ZJwV U4IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:message-id:in-reply-to:date :mime-version:dkim-signature:arc-authentication-results; bh=fiV9iJcQjxqap98CwFkr5BPL8x33fS1+9534pZZSVtY=; b=YdDYVwthFjBYaPjftmKO3jzDJasBVyeo0yf6pLkqKbVU7xmlPzRoD1slZHl32HFYmg x79KzcSoj0MGAjCZdXyTnYmm3tnUfP5Fb2lAjxnbHetu+c89k1hNH9/W76Q6V5dRXvxm zSpwdc9YhdNE60h3zfCLIBieMopKb2c+Chaez2ShzIYQzsqQqcEpxj5+tM27ZtWT1s94 VTauRrOle4zmxHkgHUTuBiDX7/jX/XIVVKv6jB5PoGNCU5zEgijBDJ6+3YRKOMocryJV 3EGYov5vJq5wVFLl/WgNAF8Y87zzxhCZU07VimDzbaxfo9vA9YONVRarlM87dkuTewRa cBKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fM3yjh0f; spf=pass (google.com: domain of 3xuaowwckcf4cpdahajckkcha.8kihejqt-iigr68g.knc@flex--gthelen.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3xUAOWwcKCF4CPDAHAJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--gthelen.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id f2-v6sor16565528uac.170.2018.05.29.23.12.21 for (Google Transport Security); Tue, 29 May 2018 23:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of 3xuaowwckcf4cpdahajckkcha.8kihejqt-iigr68g.knc@flex--gthelen.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fM3yjh0f; spf=pass (google.com: domain of 3xuaowwckcf4cpdahajckkcha.8kihejqt-iigr68g.knc@flex--gthelen.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3xUAOWwcKCF4CPDAHAJCKKCHA.8KIHEJQT-IIGR68G.KNC@flex--gthelen.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:in-reply-to:message-id:references:subject:from:to :cc; bh=fiV9iJcQjxqap98CwFkr5BPL8x33fS1+9534pZZSVtY=; b=fM3yjh0fk1iQjkJI3hzWgZUVBrNel6u3l+mJj3Ao9ecxEJaAM17rpVWJClbdgZqs30 jpsEeddCMjwLm65NXnz6OaJXbt2YMgUsuuIgZBKNIBYW3S7xRFMBuTT5svICLxZC2eE3 9eRmdi+zilGZIVbFrRspxEuMFxJ7kdC+sBocYo13CGkGXSO2VS1CVqU+Gy2aVob62hOG 9uwGtj3+5VbO62yKhZJtdyMG5HZo0DUz4PUhUi75Pl93NDgL/yNK3p6REeAm2dOnmRDb PgM9M/gmjpok4f1cuCRLZkCIovyrG8rDi7MheKIv5kcIFElaNk5vYk2v8vPLdGFfejH2 MrbQ== X-Google-Smtp-Source: ADUXVKLIghaRxucDq4HAR4mm1GhN7OtlYJSUhvIyh0TXKncZQzvPf/DUV3uMXNVAT3hzsCIr4F1C5E6fjWD+ MIME-Version: 1.0 X-Received: by 2002:ab0:50f8:: with SMTP id d53-v6mr301428uaa.88.1527660741660; Tue, 29 May 2018 23:12:21 -0700 (PDT) Date: Tue, 29 May 2018 23:12:12 -0700 In-Reply-To: <20180529025722.GA25784@bombadil.infradead.org> Message-Id: <20180530061212.84915-1-gthelen@google.com> References: <20180529025722.GA25784@bombadil.infradead.org> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog Subject: [PATCH v2] mm: condense scan_control From: Greg Thelen To: Andrew Morton , Michal Hocko , Johannes Weiner , Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Greg Thelen 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 Use smaller scan_control fields for order, priority, and reclaim_idx. Convert fields from int => s8. All easily fit within a byte: * allocation order range: 0..MAX_ORDER(64?) * priority range: 0..12(DEF_PRIORITY) * reclaim_idx range: 0..6(__MAX_NR_ZONES) Since commit 6538b8ea886e ("x86_64: expand kernel stack to 16K") x86_64 stack overflows are not an issue. But it's inefficient to use ints. Use s8 (signed byte) rather than u8 to allow for loops like: do { ... } while (--sc.priority >= 0); Add BUILD_BUG_ON to verify that s8 is capable of storing max values. This reduces sizeof(struct scan_control): * 96 => 80 bytes (x86_64) * 68 => 56 bytes (i386) scan_control structure field order is changed to utilize padding. After this patch there is 1 bit of scan_control padding. Signed-off-by: Greg Thelen Suggested-by: Matthew Wilcox --- mm/vmscan.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9b697323a88c..42731faea306 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -65,12 +65,6 @@ struct scan_control { /* How many pages shrink_list() should reclaim */ unsigned long nr_to_reclaim; - /* This context's GFP mask */ - gfp_t gfp_mask; - - /* Allocation order */ - int order; - /* * Nodemask of nodes allowed by the caller. If NULL, all nodes * are scanned. @@ -83,12 +77,6 @@ struct scan_control { */ struct mem_cgroup *target_mem_cgroup; - /* Scan (total_size >> priority) pages at once */ - int priority; - - /* The highest zone to isolate pages for reclaim from */ - enum zone_type reclaim_idx; - /* Writepage batching in laptop mode; RECLAIM_WRITE */ unsigned int may_writepage:1; @@ -111,6 +99,18 @@ struct scan_control { /* One of the zones is ready for compaction */ unsigned int compaction_ready:1; + /* Allocation order */ + s8 order; + + /* Scan (total_size >> priority) pages at once */ + s8 priority; + + /* The highest zone to isolate pages for reclaim from */ + s8 reclaim_idx; + + /* This context's GFP mask */ + gfp_t gfp_mask; + /* Incremented by the number of inactive pages that were scanned */ unsigned long nr_scanned; @@ -3047,6 +3047,14 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, .may_swap = 1, }; + /* + * scan_control uses s8 fields for order, priority, and reclaim_idx. + * Confirm they are large enough for max values. + */ + BUILD_BUG_ON(MAX_ORDER > S8_MAX); + BUILD_BUG_ON(DEF_PRIORITY > S8_MAX); + BUILD_BUG_ON(MAX_NR_ZONES > S8_MAX); + /* * Do not enter reclaim if fatal signal was delivered while throttled. * 1 is returned so that the page allocator does not OOM kill at this