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 E8495C6FD1D for ; Tue, 14 Mar 2023 10:29:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A1836B0072; Tue, 14 Mar 2023 06:29:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 650A26B0074; Tue, 14 Mar 2023 06:29:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5186A8E0001; Tue, 14 Mar 2023 06:29:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3DC706B0072 for ; Tue, 14 Mar 2023 06:29:32 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0897616048A for ; Tue, 14 Mar 2023 10:29:32 +0000 (UTC) X-FDA: 80567132184.05.44FCBAE Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf10.hostedemail.com (Postfix) with ESMTP id 1B578C001F for ; Tue, 14 Mar 2023 10:29:29 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=ZAJM0LIj; spf=pass (imf10.hostedemail.com: domain of haifeng.xu@shopee.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=haifeng.xu@shopee.com; dmarc=pass (policy=reject) header.from=shopee.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678789770; 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=/RQ7mWXsm5nOn5iTdig0BZupC24/edzn6kL9P/DXE88=; b=jAdUazwNMJv177dFp/1T26cQSDSC12B09OYYNgv5haWmXCfOZygg0Lb0lMYr5zBUHIeDPj QNt8aNT0Pi2q/ZpXeMymcPNMpBYQaBOVAJBNQn9amb6hzOm0wdkIfalkU3EbnwWmLKscLC CGGHv7YSrk5rXlGDuzM0B9aBcpdaULY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=shopee.com header.s=shopee.com header.b=ZAJM0LIj; spf=pass (imf10.hostedemail.com: domain of haifeng.xu@shopee.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=haifeng.xu@shopee.com; dmarc=pass (policy=reject) header.from=shopee.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678789770; a=rsa-sha256; cv=none; b=in4FNziSsGzK2DcKgAcOSUzkkfv1VPlEkXf54Ia4NUlU6P8wVcY0DwXflH8zctBxkuq8zk hNRO3/rqHLnqqFuqsZj5YLDrv5cpgBsySTjardOewREwF1G1eWrfFNwyl51rKVErR62Lqj GVhTVwkcDC7SDTaMzgBnAklDcoYILPk= Received: by mail-pj1-f46.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so14665661pjp.2 for ; Tue, 14 Mar 2023 03:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1678789769; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=/RQ7mWXsm5nOn5iTdig0BZupC24/edzn6kL9P/DXE88=; b=ZAJM0LIjrseRVXre3LRe6Al3qgCDvyKlNDAKUm0HNH8KyTcd1lbeCDLjCfMNRtWpou nZVtvgC7k4k+bqLCoZFbTZXaV9Z99VVW7aGCAR0UtaXvseq27HJQHgtLZ60mo42MyWmw kddHwuLnRBKrey0aGh3J7V5L6/Yx2RPX1H38/B0je4w+X/jNJre59GvKeKW1kK+jLq2n tODx8VAszrAI6aBkjDAtarfbiJkMHDTwXshgUUiQmAiFFuNNgMY3dM0iZR005fpVX/5q khM6PZopUlU234RXSU2Nx53h7jBBb3FcMe+OJhag7y81sRg8vi3FDU38JLaw//AmSKlh muCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678789769; h=content-transfer-encoding:in-reply-to:from: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=/RQ7mWXsm5nOn5iTdig0BZupC24/edzn6kL9P/DXE88=; b=sXWWjqk1uLsgDywNYCtyAflmuSNqk9CSNqMpwTqbAUl3imZbZvjHe9TQn3Ny2r8xaY kwEhOs7OK47xi5qRUNFeGGHYCP9kwtHMv4A9LYfRziIvut0fM5uNpnsCIwt6LUXiaGAA XJyrm7wUgdSi6yuGMEjphPp0GMk9YeYt/jeNKiVcJOrXaNSu8i1feNrZDDTJwFKcEikL rMUENbJI1oZp5DqyiNCsT5jmGOEyElT9l7r3R4bIbSXkJ0N/f1JCR2x0ZIJTX1S9Y8Fz q373+PO1cjaScWjG1uWpUjTf0D+AcJWFD6J/QU1w9UGzgDrSLC2sjgw/Qw5VwSfl7YG8 l4DQ== X-Gm-Message-State: AO0yUKWSPo6lDjVJ1O53LDUN/BRQB1+DF6xSXiATaK4BybTbp2R+9VXc RR8WQJMMhya6thRaFY7Ct2Q5qg== X-Google-Smtp-Source: AK7set9mUSvk/kq+Bk4twl54/IKbbe4N6ucB0PK4Q97gelKvrEI7IzhE/28YDnL9BFzdhnlStGGixg== X-Received: by 2002:a17:90b:1b0c:b0:237:97a3:1479 with SMTP id nu12-20020a17090b1b0c00b0023797a31479mr40754894pjb.28.1678789768905; Tue, 14 Mar 2023 03:29:28 -0700 (PDT) Received: from [10.54.24.141] ([143.92.118.3]) by smtp.gmail.com with ESMTPSA id gk14-20020a17090b118e00b00230b8431323sm1404793pjb.30.2023.03.14.03.29.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Mar 2023 03:29:28 -0700 (PDT) Message-ID: <1b21ee01-116d-d432-7308-8515510c89f2@shopee.com> Date: Tue, 14 Mar 2023 18:29:24 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] mm: remove redundant check in handle_mm_fault To: David Hildenbrand , 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> <562e9cc3-d0aa-23e9-bd19-266b5aef2ae7@redhat.com> <70abf872-99d1-6ff4-3332-d86d320abff2@redhat.com> From: Haifeng Xu In-Reply-To: <70abf872-99d1-6ff4-3332-d86d320abff2@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: f51j4prgymgq6fwtw4pn5akx59h1zugk X-Rspamd-Queue-Id: 1B578C001F X-HE-Tag: 1678789769-303211 X-HE-Meta: U2FsdGVkX1/EHVylGiMD5B/CnYS8BmkaR1m+3sjhDOvv2mizJ5J3ROmprpCiir1IrKK++rnNkXxHCSZ3IxWodpLYfEQNB841a5GjYZNpBl1Rs8JedFIfSBmIlf1YOfnIqlkLiqTPTIQP/qC/7IJZf4uB4b2I1XXm+AN9IuN94st81tA0ajWPSN0FcG7cKCpCms8ty3Ldf6//7RMLx8dyGynq9HhAfOcD8pNPlw6Yz929W8QaSxZb40P+JwdB0KgZe+xLLt7+Z55OMfjzpUOjp5PqDtTSxxStVk164lYYqV8IOwujy8mFW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OMkWIUc56HdS0DX 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 2023/3/14 17:09, David Hildenbrand wrote: > On 14.03.23 09:05, Haifeng Xu wrote: >> >> >> On 2023/3/8 17:13, David Hildenbrand wrote: >>> 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 ;) ). >>> >> >> Hi Daivd, the details of test result were posted last week. Do you have any suggestions or more concerns about this change? > > No, I guess it really doesn't matter performance wise. > > One valid question would be: why perform this change at all? The redundancy doesn't seem to harm performance either. > > If the change would obviously improve code readability it would be easy to justify. I'm not convinced, that is the case, but maybe for others. Yes, this change doesn't optimize performance, just improve the code readability. It seems that nobody ack this change, should I change the commit message and resend this patch? Thanks. > > So FWIW, the change looks good to me and should not affect performance in one way or the other. So no objections from my side ... >