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 7A470C433F5 for ; Fri, 11 Mar 2022 03:22:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB2A98D0002; Thu, 10 Mar 2022 22:22:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A62A08D0001; Thu, 10 Mar 2022 22:22:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 903898D0002; Thu, 10 Mar 2022 22:22:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 7CDD08D0001 for ; Thu, 10 Mar 2022 22:22:49 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 454E423F6A for ; Fri, 11 Mar 2022 03:22:49 +0000 (UTC) X-FDA: 79230658458.15.F703FEB Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by imf08.hostedemail.com (Postfix) with ESMTP id AAB6216001B for ; Fri, 11 Mar 2022 03:22:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.20.42.95]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxr8+AwCpigQQHAA--.26072S3; Fri, 11 Mar 2022 11:22:42 +0800 (CST) From: wangjianxing Subject: Re: [PATCH 1/1] mm/page_alloc: add scheduling point to free_unref_page_list To: Vlastimil Babka , Andrew Morton Cc: Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220302013825.2290315-1-wangjianxing@loongson.cn> <20220309170517.05facf4a2d183cc9aac9196d@linux-foundation.org> <3713cb82-9596-9916-9830-c2827d6a6fe4@loongson.cn> <20220309192947.0b4c8c875c492de09c1ab632@linux-foundation.org> <6dd8965e-3dd5-895b-641c-a04fa2b1115e@suse.cz> Message-ID: <9dd723a4-64e9-feac-0f84-61c129fc85e4@loongson.cn> Date: Fri, 11 Mar 2022 11:22:40 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <6dd8965e-3dd5-895b-641c-a04fa2b1115e@suse.cz> Content-Type: multipart/alternative; boundary="------------14B8C12C0F9342ABF3100568" Content-Language: en-US X-CM-TRANSID:AQAAf9Dxr8+AwCpigQQHAA--.26072S3 X-Coremail-Antispam: 1UD129KBjvJXoW7GryfGFy8ZF1ktFWxAw47Arb_yoW8JrWUpF WFq34vyr4DWa18XwsFyF1vqrn5Aw43X343AF4rKF43Ar15trn0gr92934Iqr1Uur4rZr4I vrWvgrWxu3WvqaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvjb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAv7VC0I7IY x2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4 x0Y48IcVAKI48JMx8GjcxK6IxK0xIIj40E5I8CrwCYjI0SjxkI62AI1cAE67vIY487MxkI ecxEwVCm-wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r106r1rMI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1l IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_ Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUqW xRDUUUU X-CM-SenderInfo: pzdqwyxldq5xtqj6z05rqj20fqof0/ X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: AAB6216001B X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf08.hostedemail.com: domain of wangjianxing@loongson.cn designates 114.242.206.163 as permitted sender) smtp.mailfrom=wangjianxing@loongson.cn X-Stat-Signature: 3co4mmt47zmtbtyxxtkb3fs4wwqragcf X-HE-Tag: 1646968966-699163 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: This is a multi-part message in MIME format. --------------14B8C12C0F9342ABF3100568 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit >2) find out how long the tlb batches actually are and make them smaller PAGE_SIZE is 16k other than 4k in my kernel configuration, batch count max is 2015. currently MAX_GATHER_BATCH depends on PAGE_SIZE, I will make batch's max size smaller without depending on PAGE_SIZE. #define MAX_GATHER_BATCH   ((PAGE_SIZE - sizeof(struct mmu_gather_batch)) / sizeof(void *)) On 03/10/2022 05:11 PM, Vlastimil Babka wrote: > On 3/10/22 04:29, Andrew Morton wrote: >> On Thu, 10 Mar 2022 10:48:41 +0800 wangjianxing wrote: >> >>> spin_lock will preempt_disable(), interrupt context will >>> __irq_enter/local_bh_disable and also add preempt count with offset. >>> >>> cond_resched check whether if preempt_count == 0 in first and won't >>> schedule in previous context. >>> >>> Is this right? >>> >>> >>> With another way, could we add some condition to avoid call cond_resched >>> in interrupt context or spin_lock()? >>> >>> + if (preemptible()) >>> +       cond_resched(); >>> >> None of this works with CONFIG_PREEMPTION=n. > Yeah I think we have at least two options. > > 1) check all callers, maybe realize all have enabled interrupts anyway, > rewrite the locking to only assume those > > 2) find out how long the tlb batches actually are and make them smaller --------------14B8C12C0F9342ABF3100568 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
>2) find out how long the tlb batches actually are and make them smaller
PAGE_SIZE is 16k other than 4k in my kernel configuration, batch count max is 2015.
currently MAX_GATHER_BATCH depends on PAGE_SIZE, I will make batch's max size smaller without depending on PAGE_SIZE.

#define MAX_GATHER_BATCH   ((PAGE_SIZE - sizeof(struct mmu_gather_batch)) / sizeof(void *))

On 03/10/2022 05:11 PM, Vlastimil Babka wrote:
On 3/10/22 04:29, Andrew Morton wrote:
On Thu, 10 Mar 2022 10:48:41 +0800 wangjianxing <wangjianxing@loongson.cn> wrote:

spin_lock will preempt_disable(), interrupt context will 
__irq_enter/local_bh_disable and also add preempt count with offset.

cond_resched check whether if preempt_count == 0 in first and won't 
schedule in previous context.

Is this right?


With another way, could we add some condition to avoid call cond_resched 
in interrupt context or spin_lock()?

+ if (preemptible())
+       cond_resched();

None of this works with CONFIG_PREEMPTION=n.
Yeah I think we have at least two options.

1) check all callers, maybe realize all have enabled interrupts anyway,
rewrite the locking to only assume those

2) find out how long the tlb batches actually are and make them smaller

--------------14B8C12C0F9342ABF3100568--