Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2927259pxa; Tue, 18 Aug 2020 01:35:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3/yGZU0R3yrMiHeteotLGeUVC3JYtXnfI6PYmFb3FudovbqGr5rDxyxA6N1Eb6n09+noY X-Received: by 2002:a17:907:100f:: with SMTP id ox15mr19977186ejb.125.1597739713847; Tue, 18 Aug 2020 01:35:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597739713; cv=none; d=google.com; s=arc-20160816; b=pprHskfplvTrmp9gevEqUtuC7iRmcCyKVxNxYsO1fUy2Lf/rnTVMYLAAEQcP05lgMi Oe3ON7LP8+PJhAvMnbpCGvGjJyRIveNO2pgBQ/aS0qAO0Z/5tofghztPZQA2bLcanfxn KJpTvjtpfEyq7LBk0Ua7cZtQjuQeX4GRRLeqP7/9m2g9ZBpVXsYjr3H++nMv/RWxE/Uu +kHLjXqIym8vwOPggotTwFSjrf/CfnHgEWYbJaZAgEjm5eL035nOs4m903BxpNRwEUsG WhtEv4bf9V+W93SU7EcfVi748ZEZO5QtlMej+X8p5esgeYN3AyarvOY9euuvRQ+PpsM5 LRdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=2NWaznV6FDuj2GvkVsGB+9lIi2/Tp7UcnHSniqBwDdY=; b=wZmOr3g9O7rq9jPl+5cvC8dpzCFSXwYdQoL24AlL3cfXiE73mF6BUIRxUOWYy9LXf6 PiRrw/+bNVUWWsXHBxQGj3qy+DOA4nDGFpywE7Rx/Dlf6ktijLxupaok6sA67SpUQz5b s8mn5B86f+TGgaQXnWlmCCXyfvMloVc7y9oz9nPhDiIBulJHCF2usXK5uL3k5i5E+8i8 TA5ote7/YapVJJHRqL9Bgzn5PnUIBgCouVhDff2lF+T72qi5M/7slGp/FASjq0y8rBuW 9wYkPWdZlXUsoLtcJl2Mk/V7SZKMHaZdGs1kbe8QoinObWsWWG1UMxW8aIG6uuZd0m07 4XwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x10si12879111ejc.114.2020.08.18.01.34.50; Tue, 18 Aug 2020 01:35:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726539AbgHRIeW (ORCPT + 99 others); Tue, 18 Aug 2020 04:34:22 -0400 Received: from smtp.h3c.com ([60.191.123.56]:1399 "EHLO h3cspam01-ex.h3c.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgHRIeW (ORCPT ); Tue, 18 Aug 2020 04:34:22 -0400 Received: from DAG2EX03-BASE.srv.huawei-3com.com ([10.8.0.66]) by h3cspam01-ex.h3c.com with ESMTPS id 07I8XRYb061208 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 18 Aug 2020 16:33:27 +0800 (GMT-8) (envelope-from tian.xianting@h3c.com) Received: from localhost.localdomain (10.99.212.201) by DAG2EX03-BASE.srv.huawei-3com.com (10.8.0.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 18 Aug 2020 16:33:30 +0800 From: Xianting Tian To: , CC: , , Xianting Tian Subject: [PATCH] mm/memory-failure: do pgoff calculation before for_each_process() Date: Tue, 18 Aug 2020 16:26:47 +0800 Message-ID: <20200818082647.34322-1-tian.xianting@h3c.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.99.212.201] X-ClientProxiedBy: BJSMTP01-EX.srv.huawei-3com.com (10.63.20.132) To DAG2EX03-BASE.srv.huawei-3com.com (10.8.0.66) X-DNSRBL: X-MAIL: h3cspam01-ex.h3c.com 07I8XRYb061208 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no need to calcaulate pgoff in each loop of for_each_process(), so move it to the place before for_each_process(), which can save some CPU cycles. Signed-off-by: Xianting Tian --- mm/memory-failure.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 47b8ccb1f..7dc2c9d3b 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -484,11 +484,12 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill, struct vm_area_struct *vma; struct task_struct *tsk; struct address_space *mapping = page->mapping; + pgoff_t pgoff; i_mmap_lock_read(mapping); read_lock(&tasklist_lock); + pgoff = page_to_pgoff(page); for_each_process(tsk) { - pgoff_t pgoff = page_to_pgoff(page); struct task_struct *t = task_early_kill(tsk, force_early); if (!t) -- 2.17.1