Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3374442ybt; Tue, 23 Jun 2020 00:13:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI1zzoNqIGa6pDE8DdMz6cgMbFLzsK/JpcyvHDgtZLYd5RbY6FFEOw3f4POQApXoXosqGO X-Received: by 2002:a17:907:94ca:: with SMTP id dn10mr18304071ejc.348.1592896425136; Tue, 23 Jun 2020 00:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592896425; cv=none; d=google.com; s=arc-20160816; b=XUb2VY3NDpiu1UJP+rZt0NzY8yJj6WyQZDtMRlaEtARXIfp+HW1dWhkirIJSoJjmlC Yn3dDhzZmLhqLNGAkugd/VFma3Immoqydv2GGlIbxmv+XMnAKUd63BgNWFVMcTYMS2Uy ++VkPXqAeBpgskYvAv+BLoz9dgavNExq0XS0AIve232j6G3MRb7b9VoqlJJVLZ+nwfZq wfEmFjTBKYTTy5rqjYE1LuJN+DjTLa+Cm8sKGLFQKcYKktH3XhY9dylhyQjDtx6v1qc1 m3sQiR1KXhxSbvzRSXc7WhZGF6O+kNh+etuedh6IwD/yDstM62Ley/Gp+0OxuopKyo4v nR5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=eRfic2uNti/UNHIf238bWji3fE0ROmFtREqb8C//tds=; b=Sleg12JRyqBNonEZZimflNiLh90xWnO9o3o78cap+wP365a6x1AcOGVehBoBhCEpGr 1ofRPy+xoufSZG5b8rtjxxI9P3OWujbpS5qptBA60IGBgZNT6VYyWifLAJxsl4yoTG3S I/eGUo/LeWX51Wak5rGQaInXKDxq6qno2bdWcs5voF+JKOj+onQmhe/HLCZ/eBeH9Z0j qcVFVAegH5X5ajX4U+SVmzUdX7iGh7tM/7l4r6SN4KwqbfOqGKN/u7O5of2lcZgey0OF DvGnKDFP6dtjMl5iRiHyqdCVy45DLbLupOw7Zh5EHqlZ2PiPeCVCYKdQZk43vdlq8eiQ xIAw== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a18si336482edn.607.2020.06.23.00.13.22; Tue, 23 Jun 2020 00:13:45 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731217AbgFWHLa (ORCPT + 99 others); Tue, 23 Jun 2020 03:11:30 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:34831 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730977AbgFWHL3 (ORCPT ); Tue, 23 Jun 2020 03:11:29 -0400 Received: by mail-wm1-f67.google.com with SMTP id g21so2045502wmg.0 for ; Tue, 23 Jun 2020 00:11:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eRfic2uNti/UNHIf238bWji3fE0ROmFtREqb8C//tds=; b=qr/r8LGx+ZStv1B//2nqrbCGN08vyxsjcFOICMCS8KCalpnNMVRGtL9cGNLiYL4+43 XcUEbVFtamSj8phL9xQt9OQ8PTuCAk23+etotZZEd6XPqQZh2QFS8FhJ72BqVR1B3dkA sJ+A7GLtgSqATkZ9s2V62TOV5vzvKP1OhoPtqwdaxHgxb/LaP6Q47H0BWQlnDvHHds19 nyNQSSSmICTVWIJu+k5/z8ro8HABQKd0Yem7yqJQZiR10zMRg2uImHyFVmVzo8/g5/0W ekYg0ScdpKFUePhS1a1eUrK8Tp958NH8M0T9PTQIom2lkDT0igkbmZ1kej5Fiz5FAo5H hloQ== X-Gm-Message-State: AOAM531+JWwGuA33DfJxAJRYzK+o7soxWqglOYvRW6EydyaMowAvB8Ri R5QlRO3ZG44ecvPqOhHTosc= X-Received: by 2002:a7b:cb56:: with SMTP id v22mr23073532wmj.180.1592896287624; Tue, 23 Jun 2020 00:11:27 -0700 (PDT) Received: from localhost (ip-37-188-173-135.eurotel.cz. [37.188.173.135]) by smtp.gmail.com with ESMTPSA id l190sm2452668wml.12.2020.06.23.00.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2020 00:11:26 -0700 (PDT) Date: Tue, 23 Jun 2020 09:11:25 +0200 From: Michal Hocko To: Mel Gorman Cc: Mel Gorman , ????????? , "vbabka@suse.cz" , "bhe@redhat.com" , "minchan@kernel.org" , "hannes@cmpxchg.org" , "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "jaewon31.kim@gmail.com" , ????????? , ????????? Subject: Re: [PATCH v4] page_alloc: consider highatomic reserve in watermark fast Message-ID: <20200623071125.GP31426@dhcp22.suse.cz> References: <20200622091107.GC31426@dhcp22.suse.cz> <20200619235958.11283-1-jaewon31.kim@samsung.com> <20200622094020epcms1p639cc33933fbb7a9d578adb16a6ea0734@epcms1p6> <20200622100439.GQ3183@techsingularity.net> <20200622142304.GD31426@dhcp22.suse.cz> <20200622162501.GJ3129@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200622162501.GJ3129@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 22-06-20 17:25:01, Mel Gorman wrote: > On Mon, Jun 22, 2020 at 04:23:04PM +0200, Michal Hocko wrote: > > On Mon 22-06-20 11:04:39, Mel Gorman wrote: > > > On Mon, Jun 22, 2020 at 06:40:20PM +0900, ????????? wrote: > > > > >But more importantly, I have hard time to follow why we need both > > > > >zone_watermark_fast and zone_watermark_ok now. They should be > > > > >essentially the same for anything but order == 0. For order 0 the > > > > >only difference between the two is that zone_watermark_ok checks for > > > > >ALLOC_HIGH resp ALLOC_HARDER, ALLOC_OOM. So what is exactly fast about > > > > >the former and why do we need it these days? > > > > > > > > > > > > > I think the author, Mel, may ansewr. But I think the wmark_fast may > > > > fast by 1) not checking more condition about wmark and 2) using inline > > > > rather than function. According to description on commit 48ee5f3696f6, > > > > it seems to bring about 4% improvement. > > > > > > > > > > The original intent was that watermark checks were expensive as some of the > > > calculations are only necessary when a zone is relatively low on memory > > > and the check does not always have to be 100% accurate. This is probably > > > still true given that __zone_watermark_ok() makes a number of calculations > > > depending on alloc flags even if a zone is almost completely free. > > > > OK, so we are talking about > > if (alloc_flags & ALLOC_HIGH) > > min -= min / 2; > > > > if (unlikely((alloc_flags & (ALLOC_HARDER|ALLOC_OOM))) { > > /* > > * OOM victims can try even harder than normal ALLOC_HARDER > > * users on the grounds that it's definitely going to be in > > * the exit path shortly and free memory. Any allocation it > > * makes during the free path will be small and short-lived. > > */ > > if (alloc_flags & ALLOC_OOM) > > min -= min / 2; > > else > > min -= min / 4; > > } > > > > Is this something even measurable and something that would justify a > > complex code? If we really want to keep it even after these changes > > which are making the two closer in the cost then can we have it > > documented at least? > > It was originally documented as being roughly 4% for a page allocator > micro-benchmark but that was 4 years ago and I do not even remember what > type of machine that was on. Chances are the relative cost is different > now but I haven't measured it as the microbenchmark in question doesn't > even compile with recent kernels. Thanks for the clarification. > For many allocations, the bulk of the > allocation cost is zeroing the page so I have no particular objection > to zone_watermark_fast being removed if it makes the code easier to > read. While I have not looked recently, the cost of allocation in general > and the increasing scope of the zone->lock with larger NUMA nodes for > high-order allocations like THP are more of a concern than two branches > and potentially two minor calculations. OK, then I would rather go with the code simplification for the future maintainability. If somebody can test this and provide good numbers then we can reintroduce a fast check. Thanks! -- Michal Hocko SUSE Labs