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 D22CCC433EF for ; Fri, 11 Mar 2022 09:20:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D8088D0002; Fri, 11 Mar 2022 04:20:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 488AC8D0001; Fri, 11 Mar 2022 04:20:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34F048D0002; Fri, 11 Mar 2022 04:20:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id 259908D0001 for ; Fri, 11 Mar 2022 04:20:13 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C92768249980 for ; Fri, 11 Mar 2022 09:20:12 +0000 (UTC) X-FDA: 79231559064.22.0BD2AA3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 3368C140019 for ; Fri, 11 Mar 2022 09:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646990411; 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=JjMnaabkCThW4LfIHa74LeIIYTcgnA3J8O+F2l0SgkM=; b=cGVMTvlkkHD+gH4h/oHWeEDsr9hWbhpCetJ2ua+1yGnV0qkMZqCATqV2oVNbGVoXAd3+lM sFR+1F0fnvt/Qmbgrq5hFszzLJqjo/DIBbMUFr0dunyuoQCRQFkudKrr+WbO5tk0E7Fxy8 gyG/+IH+LdPexRFemaMEScWySWqa/H0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-aDy5TzBjMfCv3QGuFTkYSA-1; Fri, 11 Mar 2022 04:20:10 -0500 X-MC-Unique: aDy5TzBjMfCv3QGuFTkYSA-1 Received: by mail-wm1-f70.google.com with SMTP id l1-20020a1c2501000000b00389c7b9254cso3022293wml.1 for ; Fri, 11 Mar 2022 01:20:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=JjMnaabkCThW4LfIHa74LeIIYTcgnA3J8O+F2l0SgkM=; b=kFPO7bvG0DCY0I6MQ3iFjfTeenVjToMOWT5ibmASUkoiSupUhraFa4s25BNEndNMHE /knrinQFbuj8dr85zoh+zYnTiK8QODmGbNO7NlEf8+xLLGFJbLc42Fn+ILjk1B4FP7TY jwV9FEu9/eOD5lD1v4bQKJU4W44EubfNVasXaWCyneazSqkLYEYCnLngXwhD/IvuSwy5 nsnM1gmmRbc2BGBnbq/9mazRhPZzVzTF1np602HmxxlBxEkBRgpdj85OhgChkiQufLXJ aaCeyq7aHQWl5O5Q7dxSg9KaZyflHDgDZxc7/i64Ifm++b3EgnNgnLcYDKBnSF6cAoLh RwYw== X-Gm-Message-State: AOAM530rlYr/NiZtMDvBonD2qjAodUzTnwSTQz7iu2YULRvfHlmIKrdo oF9nMgd9+RKMhpv2IWGfhUNnVTJCrKV2Us8DOEA2USpXLKYNVCR0yw/ScrCvLoJrrmPYVO/jiNf dglEnUqVuvpA= X-Received: by 2002:a05:6000:1847:b0:203:813a:509e with SMTP id c7-20020a056000184700b00203813a509emr6485326wri.329.1646990409470; Fri, 11 Mar 2022 01:20:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJx059XXbXV5c+1JfZ3BucwQzUjl7dzAZ6gRMB7RhWqx+WgCAbRdWc2w8xLDzsxYVlTt8YiWVQ== X-Received: by 2002:a05:6000:1847:b0:203:813a:509e with SMTP id c7-20020a056000184700b00203813a509emr6485304wri.329.1646990409203; Fri, 11 Mar 2022 01:20:09 -0800 (PST) Received: from ?IPV6:2003:cb:c707:8200:163d:7a08:6e61:87a5? (p200300cbc7078200163d7a086e6187a5.dip0.t-ipconnect.de. [2003:cb:c707:8200:163d:7a08:6e61:87a5]) by smtp.gmail.com with ESMTPSA id p11-20020adf9d8b000000b001f063deef80sm6101400wre.86.2022.03.11.01.20.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Mar 2022 01:20:08 -0800 (PST) Message-ID: <52412f08-829a-6c29-60c6-a24c866e6253@redhat.com> Date: Fri, 11 Mar 2022 10:20:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH] mm/khugepaged: sched to numa node when collapse huge page To: Bibo Mao , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220311090119.2412738-1-maobibo@loongson.cn> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220311090119.2412738-1-maobibo@loongson.cn> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3368C140019 X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cGVMTvlk; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf26.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: rpxbfjcuzdidtz7rhwb64cbz3aa63w7b X-HE-Tag: 1646990412-953313 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 11.03.22 10:01, Bibo Mao wrote: > collapse huge page is slow, specially when khugepaged daemon runs > on different numa node with that of huge page. It suffers from > huge page copying across nodes, also cache is not used for target > node. With this patch, khugepaged daemon switches to the same numa > node with huge page. It saves copying time and makes use of local > cache better. Hi, just the usual question, do you have any performance numbers to back your claims (e.g., "is slow, specially when") and proof that this patch does the trick? > > Signed-off-by: Bibo Mao > --- > mm/khugepaged.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > index 131492fd1148..460c285dc974 100644 > --- a/mm/khugepaged.c > +++ b/mm/khugepaged.c > @@ -116,6 +116,7 @@ struct khugepaged_scan { > struct list_head mm_head; > struct mm_slot *mm_slot; > unsigned long address; > + int node; > }; > > static struct khugepaged_scan khugepaged_scan = { > @@ -1066,6 +1067,7 @@ static void collapse_huge_page(struct mm_struct *mm, > struct vm_area_struct *vma; > struct mmu_notifier_range range; > gfp_t gfp; > + const struct cpumask *cpumask; We tend to stick to reverse Christmas tree format as good as possible. > > VM_BUG_ON(address & ~HPAGE_PMD_MASK); > > @@ -1079,6 +1081,13 @@ static void collapse_huge_page(struct mm_struct *mm, > * that. We will recheck the vma after taking it again in write mode. > */ > mmap_read_unlock(mm); > + > + /* sched to specified node before huage page memory copy */ s/huage/huge/ > + cpumask = cpumask_of_node(node); > + if ((khugepaged_scan.node != node) && !cpumask_empty(cpumask)) { > + set_cpus_allowed_ptr(current, cpumask); > + khugepaged_scan.node = node; > + } > new_page = khugepaged_alloc_page(hpage, gfp, node); > if (!new_page) { > result = SCAN_ALLOC_HUGE_PAGE_FAIL; > @@ -2380,6 +2389,7 @@ int start_stop_khugepaged(void) > kthread_stop(khugepaged_thread); > khugepaged_thread = NULL; > } > + khugepaged_scan.node = NUMA_NO_NODE; > set_recommended_min_free_kbytes(); > fail: > mutex_unlock(&khugepaged_mutex); -- Thanks, David / dhildenb