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 X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84FF9C433E0 for ; Tue, 11 Aug 2020 10:46:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 132B120756 for ; Tue, 11 Aug 2020 10:46:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KdMQrkY1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 132B120756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4C2496B0003; Tue, 11 Aug 2020 06:46:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44C766B0005; Tue, 11 Aug 2020 06:46:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3141C6B0006; Tue, 11 Aug 2020 06:46:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id 18D9B6B0003 for ; Tue, 11 Aug 2020 06:46:03 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 96E891E16 for ; Tue, 11 Aug 2020 10:46:02 +0000 (UTC) X-FDA: 77137957764.29.wine13_00153d126fe2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 66BE918086E35 for ; Tue, 11 Aug 2020 10:46:02 +0000 (UTC) X-HE-Tag: wine13_00153d126fe2 X-Filterd-Recvd-Size: 5559 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Aug 2020 10:46:01 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id w25so12943956ljo.12 for ; Tue, 11 Aug 2020 03:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QbMPdkDZ6gl/XQAeycQLRz6hlFETojbWgl9OUCbj+o8=; b=KdMQrkY1LdGJd0zpajnMj9oxmjqrSVc1Ggja6K/3OAPivsUw0oJkKNiUY4F9waF1te XJLnps9AOaVyx0c1Tp21zoeFkUQuH89qxsROKFQ7b77W53d2REmt6Bu4TmUy+i8lWz8y vKpxJyAbci8bqRPsojduDOCfOii3mGmsZqUN49Q+xf9cYn6m+atFNVbXk2ymWuDOpCCr qs2rxr/iO4UWtrO++nxmHmAqHhwsHuYSayZxG4GgODL+GUqdSCy50rEqp66ChcBhk6mR wsrTP7gexzSD3OKV+/EGs6/L8J1rn+t00EYTY/1HBeWLr3EeOnBlt5Er4SFM6sLCbl9p zfzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QbMPdkDZ6gl/XQAeycQLRz6hlFETojbWgl9OUCbj+o8=; b=MTpx0DwpmzIuDho1BeEGQAA9yNzwVl1S0R9fmw2sxUGRSpcx+Sis2MGu+N4X1WO21g CoICJMiVnAjd8RHpBrNyoIEhi1bRnyHF3W5woH9C2O1AnJ7lym8Kr/pMFsvMk7YL0G0X t5M0i813DD4CiH/STzBisLp8m9Vnym4bPJScSqeuVEgoldAcCrPG7ihq/X1FqXUdRcBk 4NTnZJc+1KiMQBwfboMiRtnv+U7c+XKymtoXOWTBF/ro8+gC1jU2nlVhGxoK5E714Ny7 2Ve4ILL7qdkmEkzlXy1eGTDeyi1diJ77dd9X5adTAMPbc/NrsBSfYGEFRkBc3QbJ+oCz +YiA== X-Gm-Message-State: AOAM532TTXrqcXen1vn+gDH9ZzWyRpiQcKkJpTmJ4ApBFet+nNCiLnTc IGSDfiN7gIiO8VuOgwBAR+A= X-Google-Smtp-Source: ABdhPJzhc/jXUCVGVIhHeGPo2BEqY7mmIBU7D7Izx8scomgDPFT4g7QVNFF+iXyroJpk6NgUN+PwYw== X-Received: by 2002:a2e:8589:: with SMTP id b9mr2661458lji.126.1597142760327; Tue, 11 Aug 2020 03:46:00 -0700 (PDT) Received: from pc636 (h5ef52e31.seluork.dyn.perspektivbredband.net. [94.245.46.49]) by smtp.gmail.com with ESMTPSA id m12sm9353432lji.106.2020.08.11.03.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 03:45:59 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 11 Aug 2020 12:45:57 +0200 To: Michal Hocko Cc: Uladzislau Rezki , LKML , RCU , linux-mm@kvack.org, Andrew Morton , Vlastimil Babka , "Paul E . McKenney" , Matthew Wilcox , "Theodore Y . Ts'o" , Joel Fernandes , Sebastian Andrzej Siewior , Oleksiy Avramchenko Subject: Re: [RFC-PATCH 1/2] mm: Add __GFP_NO_LOCKS flag Message-ID: <20200811104557.GA5301@pc636> References: <20200809204354.20137-1-urezki@gmail.com> <20200809204354.20137-2-urezki@gmail.com> <20200810123141.GF4773@dhcp22.suse.cz> <20200810160739.GA29884@pc636> <20200810192525.GG4773@dhcp22.suse.cz> <20200811081917.GG4793@dhcp22.suse.cz> <20200811093713.GB2634@pc636> <20200811094251.GA3767@pc636> <20200811102818.GJ4793@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200811102818.GJ4793@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 66BE918086E35 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Tue, Aug 11, 2020 at 12:28:18PM +0200, Michal Hocko wrote: > On Tue 11-08-20 11:42:51, Uladzislau Rezki wrote: > > On Tue, Aug 11, 2020 at 11:37:13AM +0200, Uladzislau Rezki wrote: > > > On Tue, Aug 11, 2020 at 10:19:17AM +0200, Michal Hocko wrote: > [...] > > > > Anyway, if the zone->lock is not a good fit for raw_spin_lock then the > > > > only way I can see forward is to detect real (RT) atomic contexts and > > > > bail out early before taking the lock in the allocator for NOWAIT/ATOMIC > > > > requests. > > > > > > This is similar what i have done with mm: Add __GFP_NO_LOCKS flag. I just > > did it for order-0 pages(other paths are impossible) and made it common for > > any kernel. > > > > Because when you say "bail out early" i suspect that we would like to check > > the per-cpu-list cache. > > Bail out early means to do as much as possible until a raw non-compliant > lock has to be taken. > struct page *rmqueue(struct zone *preferred_zone, struct zone *zone, unsigned int order, gfp_t gfp_flags, unsigned int alloc_flags, int migratetype) { unsigned long flags; struct page *page; if (likely(order == 0)) { page = rmqueue_pcplist(preferred_zone, zone, gfp_flags, migratetype, alloc_flags); goto out; } /* * We most definitely don't want callers attempting to * allocate greater than order-1 page units with __GFP_NOFAIL. */ WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1)); spin_lock_irqsave(&zone->lock, flags); only order-0 allocations can be checked if CPUs pcp-list-cache has something. I mean without taking any locks, i.e. it is lockless. "Pre-fetching" is not possible since it takes zone->lock in order to do transfer pages from the buddy to the per-cpu-lists. It is done in the rmqueue_bulk() function. -- Vlad Rezki