From patchwork Wed Mar 4 20:32:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Jackson X-Patchwork-Id: 11420683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B4C7814B7 for ; Wed, 4 Mar 2020 20:32:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 825BF21775 for ; Wed, 4 Mar 2020 20:32:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JYDfCrZq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 825BF21775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 990F06B0003; Wed, 4 Mar 2020 15:32:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 91A4A6B0005; Wed, 4 Mar 2020 15:32:39 -0500 (EST) 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 808996B0007; Wed, 4 Mar 2020 15:32:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0148.hostedemail.com [216.40.44.148]) by kanga.kvack.org (Postfix) with ESMTP id 65B9E6B0003 for ; Wed, 4 Mar 2020 15:32:39 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 03F1B4417 for ; Wed, 4 Mar 2020 20:32:39 +0000 (UTC) X-FDA: 76558828038.26.scene18_8b868549c2e27 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,ajax@redhat.com,,RULES_HIT:30012:30054:30070,0,RBL:205.139.110.61:@redhat.com:.lbl8.mailshell.net-62.18.0.100 66.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: scene18_8b868549c2e27 X-Filterd-Recvd-Size: 4127 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Mar 2020 20:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583353958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5H+yeYBGEEeRP85T77PxYABsK3Vc7iKLOEM+HoeL4eQ=; b=JYDfCrZq3+14WlXU6fp0bFkAA4NCBRdEqGGr5j6iH+GdaqS5yhyz4ZOa82BLT/JN5tEf4/ VUUxEgHktYvMyTlIUIWjMymqXWwuGN7F7aH7AVZ4v26TiECTzcHPAKunkOz4JqaD6QtFZK hIy6huEIpi8qI9D00AabJgcS8UbZXYs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-uK5PSoSrNIWHS4PfkmTbqw-1; Wed, 04 Mar 2020 15:32:36 -0500 X-MC-Unique: uK5PSoSrNIWHS4PfkmTbqw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C44B6107ACCA for ; Wed, 4 Mar 2020 20:32:35 +0000 (UTC) Received: from datura.bss.redhat.com (dhcp-10-20-1-78.bss.redhat.com [10.20.1.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87D4660C80 for ; Wed, 4 Mar 2020 20:32:35 +0000 (UTC) From: Adam Jackson To: linux-mm@kvack.org Subject: [PATCH] mm/vmscan: Prioritize anonymous executable pages like we do file-backed Date: Wed, 4 Mar 2020 15:32:35 -0500 Message-Id: <20200304203235.3623103-1-ajax@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: The page reclamation scanner tries to keep executable pages resident, since taking a hard page fault to satisfy an icache miss is really not great for interactivity. Anonymous executable pages tend to contain code that has been just-in-time compiled for performance reasons. By requiring that executable pages be file-backed, we're putting possibly the most performance-sensitive code at higher risk of eviction, which seems backwards. On an amd64 machine running Fedora 31, the firefox I happen to have running requires about 89M of file-backed text and 12M of anonymous text for 30 open tabs. The next largest process in terms of anonymous text is gnome-shell, with 1M anonymous and 57M file-backed. No other process had significant anonymous text, most had none. Penalizing those 13M specifically when under memory pressure seems like an easy hazard to avoid. Signed-off-by: Adam Jackson --- mm/vmscan.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index ee4eecc7e1c2..9bfbc30d61d8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2095,15 +2095,12 @@ static void shrink_active_list(unsigned long nr_to_scan, &vm_flags)) { nr_rotated += hpage_nr_pages(page); /* - * Identify referenced, file-backed active pages and - * give them one more trip around the active list. So + * Identify referenced, executable active pages and + * give them one more trip around the active list, so * that executable code get better chances to stay in - * memory under moderate memory pressure. Anon pages - * are not likely to be evicted by use-once streaming - * IO, plus JVM can create lots of anon VM_EXEC pages, - * so we ignore them here. + * memory under moderate memory pressure. */ - if ((vm_flags & VM_EXEC) && page_is_file_cache(page)) { + if ((vm_flags & VM_EXEC)) { list_add(&page->lru, &l_active); continue; }