Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1426278pxu; Fri, 16 Oct 2020 11:37:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFnE0vo+uBvGXM2Tr0GAXJWA52DLfphmWtUmO4/itnIL1DBbKZd6DvyO1vjVZkRrp5fyd6 X-Received: by 2002:a17:906:a195:: with SMTP id s21mr5018034ejy.146.1602873442878; Fri, 16 Oct 2020 11:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602873442; cv=none; d=google.com; s=arc-20160816; b=wj04gXu+Lxvd1DyVhLjvhDDJdG3fX17zwEgZhphExJCnraEgn12DUe+oVj1tIB8Hsb 9nzAzITMEQj6QbgXXdAkemTZiDzNpvNQ0mb5LctNH6ibOkjRjkUTmryIWV0FOeM0tRuR njM2Q5pPpSsKJLwsUHKUZGIm6bOE6/QZw2kigO5AOeW9mspqrIOTXvzrx2uhRxi/GL97 n2OcqgdY9M4k3BvcDRuxpilC4G/zEh6y828lOlrXEdmPKWPcctbK+beekvHxh4HhUg8O siPdMJWqXXuU8paJWI0KBHA/NTaRRETrhu+Vo6MNYsiCa13sMl6/75GrLYU/cqEXF8kW fAlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=G9T/YfU/0aHDmEm8dYgQx+J8uiY5km41uwn3J/WONaY=; b=zWL8fS1lWTnMaRPurXEKzlbBIFooz0kpdQ/dtpc3Avr1dj3C+P1KoLxjZfgipwM7T6 6lUmnsn+OonT4DoesvcDSskHfLjUVDJT2OP6EYO9uNG4KsHuIPJgMthzU+Tmm4tNR8ke YRt+UQclidlBK5sqj6cdtuo5v2KFjQKLPwhHGoHZsoAVW2qGiwvVxjLcr7j4BuNWojp4 6/fUPMrmT0GfXKAWEcN+HvRbeb3sKULBR4p4U/oasSfmdcxrzqJMEbuYbeFQYv5lFqw2 vYHsesgh5rJAV3rYpKGszBRyUivyozgRPZS7uitrsKk0UG7etlitcsPqNGytcH5yLYRe tRlg== 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 g20si2658485ejm.339.2020.10.16.11.37.00; Fri, 16 Oct 2020 11:37:22 -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 S2407653AbgJPNVN convert rfc822-to-8bit (ORCPT + 99 others); Fri, 16 Oct 2020 09:21:13 -0400 Received: from smtp.h3c.com ([60.191.123.50]:14386 "EHLO h3cspam02-ex.h3c.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406024AbgJPNVN (ORCPT ); Fri, 16 Oct 2020 09:21:13 -0400 Received: from DAG2EX01-BASE.srv.huawei-3com.com ([10.8.0.64]) by h3cspam02-ex.h3c.com with ESMTPS id 09GDKblJ010960 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 Oct 2020 21:20:37 +0800 (GMT-8) (envelope-from tian.xianting@h3c.com) Received: from DAG2EX03-BASE.srv.huawei-3com.com (10.8.0.66) by DAG2EX01-BASE.srv.huawei-3com.com (10.8.0.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 16 Oct 2020 21:20:41 +0800 Received: from DAG2EX03-BASE.srv.huawei-3com.com ([fe80::5d18:e01c:bbbd:c074]) by DAG2EX03-BASE.srv.huawei-3com.com ([fe80::5d18:e01c:bbbd:c074%7]) with mapi id 15.01.1713.004; Fri, 16 Oct 2020 21:20:41 +0800 From: Tianxianting To: Michal Hocko CC: "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] mm: vmscan: avoid a unnecessary reschedule in shrink_slab() Thread-Topic: [PATCH] mm: vmscan: avoid a unnecessary reschedule in shrink_slab() Thread-Index: AQHWo29cMaRbAMdQE0ycFn5GylDeeqmZnPOAgACJFdD//4YYAIAAiVZw Date: Fri, 16 Oct 2020 13:20:41 +0000 Message-ID: <8a25eacf4b37460897911ade338754d3@h3c.com> References: <20201016033952.1924-1-tian.xianting@h3c.com> <20201016120749.GG22589@dhcp22.suse.cz> <9a2b772b13f84bdd9517b17d8d72aa89@h3c.com> <20201016130208.GI22589@dhcp22.suse.cz> In-Reply-To: <20201016130208.GI22589@dhcp22.suse.cz> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.99.141.128] x-sender-location: DAG2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-DNSRBL: X-MAIL: h3cspam02-ex.h3c.com 09GDKblJ010960 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks I understood what you said :) But whether it is proper to check reschedule in every loop when lock is taken? By the way, I did not met a issue for this , I just learn this code and come up with one possible optimization based my understanding. -----Original Message----- From: Michal Hocko [mailto:mhocko@suse.com] Sent: Friday, October 16, 2020 9:02 PM To: tianxianting (RD) Cc: akpm@linux-foundation.org; linux-mm@kvack.org; linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: vmscan: avoid a unnecessary reschedule in shrink_slab() On Fri 16-10-20 12:48:23, Tianxianting wrote: > Thanks, my understanding is, > In shrink_slab(), do_shrink_slab() will do the real reclaim work, which will occupy current cpu and consume more cpu time, so we need to trigger a reschedule after reclaim. > But if it jumps to 'out' label, that means we don't do the reclaim work at this time, it won't cause other thread getting starvation, so we don't need to call cond_resched() in this case. > Is it right? You are almost right. But consider situation when the lock is taken for quite some time. do_shrink_slab cannot make any forward progress and effectivelly busy loop. Unless the caller does cond_resched it might cause soft lockups. Anyway let me try to ask again. Why does would this be any problem that deserves a fix? > > -----Original Message----- > From: Michal Hocko [mailto:mhocko@suse.com] > Sent: Friday, October 16, 2020 8:08 PM > To: tianxianting (RD) > Cc: akpm@linux-foundation.org; linux-mm@kvack.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH] mm: vmscan: avoid a unnecessary reschedule in > shrink_slab() > > On Fri 16-10-20 11:39:52, Xianting Tian wrote: > > In shrink_slab(), it directly goes to 'out' label only when it can't > > get the lock of shrinker_rwsew. In this case, it doesn't do the real > > work of shrinking slab, so we don't need trigger a reschedule by > > cond_resched(). > > Your changelog doesn't explain why this is not needed or undesirable. Do you see any actual problem? > > The point of this code is to provide a deterministic scheduling point regardless of the shrinker_rwsew. > > > > > Signed-off-by: Xianting Tian > > --- > > mm/vmscan.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c index 466fc3144..676e97b28 > > 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -687,8 +687,9 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, > > } > > > > up_read(&shrinker_rwsem); > > -out: > > + > > cond_resched(); > > +out: > > return freed; > > } > > > > -- > > 2.17.1 > > > > -- > Michal Hocko > SUSE Labs -- Michal Hocko SUSE Labs