Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4458868pxk; Wed, 30 Sep 2020 03:37:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhBhm4aWjqiYGFxG48a76Nz16wcKfT7XDQI37rrNxpo1oGqtv28wsY3RDlhwr5n/jLP5T6 X-Received: by 2002:a17:906:6005:: with SMTP id o5mr1957965ejj.465.1601462269473; Wed, 30 Sep 2020 03:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601462269; cv=none; d=google.com; s=arc-20160816; b=BHp2axIiOaB2X+KBo+IRktneA53BFqA8rUuEBdoLjht3JCEb+8f9ymx9foFxGFxZjL 4UfmMJsvEeWl3+3McFpZY9gGMCe7q1Um0W9kNdWUDIFLpThi3+4HM3kc/EmHkRIiU/ts oFtzKP5UeuTB66QvXwbWVFv+2DN/mgIHm654KR6oARBckxxDT7Yc/bBhvNnjKEkGJq8C C7xI8U4UqApvW7cOGVnbsR+x8arIKVoXQZatPS7m2NF0yeFnCsd6CzX7g5bqZGBixHRK L4LmSYMbZ2SvCeE2L9jGs9rb9iME7UK1Dul9jagFl4Eag5sug0hdFxrhQ/6XW+yGNfty 5NuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=FWdudvb6rnom2+iYLotus6hARt6/ghjp6H9hbcaqJPM=; b=xKMQPbNZV6EDnSsxDuQdMRr1t69QR9C5ihkuPGEUzKupf471rKuQCG84Z2w9guYAPm U+ssdY3iok/KC/7Jir/ZGIE52SvKTTG3sPIWDaXrGgDpQ+apcGrV8xprx2n5/zUFQIVI TMfvsa4aRsbUFa+VCXLIJj764dfg1Vjqq6ciOBmZwZeJxR4Y5dBxRhTTmz20bQsUwB0X g5Jgm4Yo7P91fEBCQ4rSRVLsUSLWx0CkgBik0FrWKBYdQrskmJWASvTlsMhdEhVppXz4 Ximx8+mvSgBDFJqMCG3ozpUFxAgbEu1TwRlJNBMDVtAGILd8Brft8jLIdSCbHSFlDAci e7cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=RROXmXp0; 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=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si861132eje.193.2020.09.30.03.37.27; Wed, 30 Sep 2020 03:37:49 -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; dkim=pass header.i=@suse.com header.s=susede1 header.b=RROXmXp0; 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=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729132AbgI3Kf7 (ORCPT + 99 others); Wed, 30 Sep 2020 06:35:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:60824 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgI3Kf7 (ORCPT ); Wed, 30 Sep 2020 06:35:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601462157; 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: in-reply-to:in-reply-to:references:references; bh=FWdudvb6rnom2+iYLotus6hARt6/ghjp6H9hbcaqJPM=; b=RROXmXp0w1cns3nM5MVBGcDg3nStPGVtCMbSSSRGjR1F4MFLpamWW+1t//7hI3P928iQMY Jj46jzsy4xTUKdiE1nyI4Cujwp6dp5Yt2x8CdIcgm2zcHspoAYh+74bhBgF7/KRNpQyt6N w1h+0gZZ/Gf+zG+7YwEKDX9rAPdirvw= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A5C0BABE3; Wed, 30 Sep 2020 10:35:57 +0000 (UTC) Date: Wed, 30 Sep 2020 12:35:57 +0200 From: Michal Hocko To: Uladzislau Rezki Cc: Vlastimil Babka , LKML , RCU , linux-mm@kvack.org, Andrew Morton , "Paul E . McKenney" , Peter Zijlstra , Thomas Gleixner , "Theodore Y . Ts'o" , Joel Fernandes , Sebastian Andrzej Siewior , Oleksiy Avramchenko , Mel Gorman Subject: Re: [RFC-PATCH 2/4] mm: Add __rcu_alloc_page_lockless() func. Message-ID: <20200930103557.GQ2277@dhcp22.suse.cz> References: <20200918194817.48921-1-urezki@gmail.com> <20200918194817.48921-3-urezki@gmail.com> <38f42ca1-ffcd-04a6-bf11-618deffa897a@suse.cz> <20200929220742.GB8768@pc636> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200929220742.GB8768@pc636> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 30-09-20 00:07:42, Uladzislau Rezki wrote: [...] > > bool is_pcp_cache_empty(gfp_t gfp) > { > struct per_cpu_pages *pcp; > struct zoneref *ref; > unsigned long flags; > bool empty; > > ref = first_zones_zonelist(node_zonelist( > numa_node_id(), gfp), gfp_zone(gfp), NULL); > if (!ref->zone) > return true; > > local_irq_save(flags); > pcp = &this_cpu_ptr(ref->zone->pageset)->pcp; > empty = list_empty(&pcp->lists[gfp_migratetype(gfp)]); > local_irq_restore(flags); > > return empty; > } > > disable_irq(); > if (!is_pcp_cache_empty(GFP_NOWAIT)) > __get_free_page(GFP_NOWAIT); > enable_irq(); > > > Do you mean to have something like above? I mean some extra API > function that returns true or false if fast-fast allocation can > either occur or not. Above code works just fine and never touches > main zone->lock. The above code works with the _current_ implementation and it restricts its implementation to some degree. Future changes might get harder to implement with a pattern like this. I do not think we want users to be aware of internal implementation details like pcp caches, migrate types or others. While pcp caches are here for years and unlikely to change in a foreseeable future many details are changing on regular basis. -- Michal Hocko SUSE Labs