From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75BB6C64EC4 for ; Wed, 8 Mar 2023 09:13:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0BF36B0078; Wed, 8 Mar 2023 04:13:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BBD56B007B; Wed, 8 Mar 2023 04:13:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85DDF6B007D; Wed, 8 Mar 2023 04:13:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 741186B0078 for ; Wed, 8 Mar 2023 04:13:25 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4139280EC7 for ; Wed, 8 Mar 2023 09:13:25 +0000 (UTC) X-FDA: 80545167570.27.EE0C629 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 9F34680015 for ; Wed, 8 Mar 2023 09:13:22 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UYZ4Gpuf; spf=pass (imf02.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678266803; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nL07OXOTECIQ3+AAmmOwYpqRhIVNzr9bj2mSTEdfSNE=; b=hpRY/LADsA6Sdfsho4UQ7BpCs/Dk15j0P1LL5Q7Es7l/BmYFOooFKnviszlOtqa5jXopSy ebrleZ6wD6UxE40fqFUrFeVFH0o+DJOA03DW4ZjCqyDQtcKjkEv73JoyB7hAPK3mOR6GWb ZenU1MExHFp0qgvcWEENbqaoZbXIFOY= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UYZ4Gpuf; spf=pass (imf02.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678266803; a=rsa-sha256; cv=none; b=VSj5hq7C5NKJjpzCLbK36wWMVz1eWUcWTVWF+abbAXgssHr9rRagYkA7w13CpYknZ2W3q4 xuZcacM14iXCATPhGUzsRU5BsJNUVxSVi25kMwS9PPpRnh5Gf4BrjTrE6hqhR4bpNtk7Ug RaBqaHq8xVDXLYxwHaffpAk1MJ/TnUs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678266801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nL07OXOTECIQ3+AAmmOwYpqRhIVNzr9bj2mSTEdfSNE=; b=UYZ4GpufajpEsGvBVZkSY9TlQG6Gwyp5d+JDbNVx7NLKUUo/jd3R1VBe/T6k8wa0W1BjSV 1XZa1z1kawYjuOyL4tlmedhekEQFKiBMsjYcSzV8d7LNelJZ7q4Wv25tQYXz1rfL+qYLxG W6AVaEsXkSFch52u6R5joTvWsGQ1ZvQ= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-lEvdAIZjNS2ktcBa2MmgfQ-1; Wed, 08 Mar 2023 04:13:18 -0500 X-MC-Unique: lEvdAIZjNS2ktcBa2MmgfQ-1 Received: by mail-wr1-f71.google.com with SMTP id y11-20020a056000168b00b002ce179d1b90so2739907wrd.23 for ; Wed, 08 Mar 2023 01:13:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678266797; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nL07OXOTECIQ3+AAmmOwYpqRhIVNzr9bj2mSTEdfSNE=; b=oZbrXE0vZ1zNNs7cqnhyWzZnmn1y+TK26zug3ebUyZMXuWDAPjpHmV5ZoL2fp2c3IC uEZwUbeSX9qJRQOj+PzSY3kNfaNCwz6mdsDzwFiD500qv8XJeegLZ2RlbMLW3koB5SPU d0gVlX84WFQrnUmGiSrOUPqQP6MBN0KlP6JIDwECpWLpgDmjO+2T/0YF+VNX3mswjIpY D05R25rO9NYR5FnB0z7w8JfVRqEMYzsrOqz7FLynGOv1qsCdd3upmk5/Fo5Fx1GPCmGS eGanelLMdYHTmczzsjIAur+qxsMxlHLjzai9wHkGFibgqSh2kkFEFZi2lCGOzLnD3tTx +ivw== X-Gm-Message-State: AO0yUKXB9oJV/m2u0/l3BptR7vDqbsJGyqLvVaeZ1Rw6uz3NCP+gDlcV WyLbbhtXTDHV4ROpA0QM/dUBHRau2OOSmd7EFAxMz5LwSmkpNYgLcbXfsjxoYvlXUC2pkviSXrg aVd8KUnIbH44= X-Received: by 2002:a05:600c:4e8c:b0:3e2:dba:7155 with SMTP id f12-20020a05600c4e8c00b003e20dba7155mr14460964wmq.20.1678266797465; Wed, 08 Mar 2023 01:13:17 -0800 (PST) X-Google-Smtp-Source: AK7set88RAKW4KwEadLYLLhL+xQvkBCka/j77islJ+OlSpGWPMJoJ2je1C3IXMNMJkIRBF5Y9JIlEw== X-Received: by 2002:a05:600c:4e8c:b0:3e2:dba:7155 with SMTP id f12-20020a05600c4e8c00b003e20dba7155mr14460944wmq.20.1678266797115; Wed, 08 Mar 2023 01:13:17 -0800 (PST) Received: from ?IPV6:2003:cb:c71b:cb00:d372:1da8:9e9e:422d? (p200300cbc71bcb00d3721da89e9e422d.dip0.t-ipconnect.de. [2003:cb:c71b:cb00:d372:1da8:9e9e:422d]) by smtp.gmail.com with ESMTPSA id r18-20020a05600c35d200b003dfe549da4fsm20440570wmq.18.2023.03.08.01.13.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Mar 2023 01:13:16 -0800 (PST) Message-ID: <562e9cc3-d0aa-23e9-bd19-266b5aef2ae7@redhat.com> Date: Wed, 8 Mar 2023 10:13:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] mm: remove redundant check in handle_mm_fault To: Haifeng Xu , Matthew Wilcox Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230306024959.131468-1-haifeng.xu@shopee.com> <354360d5-dce6-a11c-ee61-d41e615bfa05@shopee.com> <6df72872-2829-47ab-552c-7ef8a6470e6f@shopee.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <6df72872-2829-47ab-552c-7ef8a6470e6f@shopee.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9F34680015 X-Stat-Signature: zd5ptdpfc87y7cxcwparqmktywr4qr75 X-Rspam-User: X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GnbRrTg3AanIBjTjf0nkhhPWxAzEvYXJm06v+bUmooY+Ck4zxGQgBMuo0R11DyaFEmOn2Y/O7espKu/eeN/+/wFRBJuzQqPk207B82H1KtQWCCacPGY0XigNJvK46igcRZMz23tbY3S1x7d3NrwI8LqVIYBanhdQ3npEccjp5ulHwS7nAR0NpeCQ0Dw+2QY6MdoqlBECSFCzQ8ptu4OhOvf4/rbGhIzCHHqlvz/Q1DPLlXtEh7gU94a6/ztd9EeFKGe7H8G/bNfpwQSW93cVJchpvznYbb 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: On 08.03.23 10:03, Haifeng Xu wrote: > > > On 2023/3/7 10:48, Matthew Wilcox wrote: >> On Tue, Mar 07, 2023 at 10:36:55AM +0800, Haifeng Xu wrote: >>> On 2023/3/6 21:49, David Hildenbrand wrote: >>>> On 06.03.23 03:49, Haifeng Xu wrote: >>>>> mem_cgroup_oom_synchronize() has checked whether current memcg_in_oom is >>>>> set or not, so remove the check in handle_mm_fault(). >>>> >>>> "mem_cgroup_oom_synchronize() will returned immediately if memcg_in_oom is not set, so remove the check from handle_mm_fault()". >>>> >>>> However, that requires now always an indirect function call -- do we care about dropping that optimization? >>>> >>>> >>> >>> If memcg_in_oom is set, we will check it twice, one is from handle_mm_fault(), the other is from mem_cgroup_oom_synchronize(). That seems a bit redundant. >>> >>> if memcg_in_oom is not set, mem_cgroup_oom_synchronize() returns directly. Though it's an indirect function call, but the time spent can be negligible >>> compare to the whole mm user falut preocess. And that won't cause stack overflow error. >> >> I suggest you measure it. > > test steps: > 1) Run command: ./mmap_anon_test(global alloc, so the memcg_in_oom is not set) > 2) Calculate the quotient of cost time and page-fault counts, run 10 rounds and average the results. > > The test result shows that whether using indirect function call or not, the time spent in user fault > is almost the same, about 2.3ms. I guess most of the benchmark time is consumed by allocating fresh pages in your test (also, why exactly do you use MAP_SHARED?). Is 2.3ms the total time for writing to that 1GiB of memory or how did you derive that number? Posting both results would be cleaner (with more digits ;) ). -- Thanks, David / dhildenb