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.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 E788CC4363A for ; Mon, 5 Oct 2020 14:10:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 73977207F7 for ; Mon, 5 Oct 2020 14:10:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="J6sJ0/9X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73977207F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B3E126B006E; Mon, 5 Oct 2020 10:10:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AED326B0070; Mon, 5 Oct 2020 10:10:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A02A56B0071; Mon, 5 Oct 2020 10:10:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0087.hostedemail.com [216.40.44.87]) by kanga.kvack.org (Postfix) with ESMTP id 70ACC6B006E for ; Mon, 5 Oct 2020 10:10:29 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 01BE0824999B for ; Mon, 5 Oct 2020 14:10:29 +0000 (UTC) X-FDA: 77338056978.17.bat15_21108cf271be Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 1D2AD1802C534 for ; Mon, 5 Oct 2020 14:05:33 +0000 (UTC) X-HE-Tag: bat15_21108cf271be X-Filterd-Recvd-Size: 3756 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Mon, 5 Oct 2020 14:05:33 +0000 (UTC) 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=1601906732; 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=mDtDQhketcq7bMXAoB6v7sjRm5Re7JG6raTUQ0gvII0=; b=J6sJ0/9XfbH2tDhmw6JcLzTejZ6/O+2B99IlIP1jiHEFQd47mJRtX5qFt5VLVsmXIUTtiO KsY/UlocAlhcdgVaax+795HYkTbvfT63EEut912Uw2J5KFN5a7K6iNqLse6WyIDnzGrnKB KZn+RafdJBQi9weioRMV6Q1DU1da5hc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 446F6ADD8; Mon, 5 Oct 2020 14:05:32 +0000 (UTC) Date: Mon, 5 Oct 2020 16:05:31 +0200 From: Michal Hocko To: Vlastimil Babka Cc: David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pavel Tatashin , Oscar Salvador , Joonsoo Kim Subject: Re: [PATCH 9/9] mm, page_alloc: optionally disable pcplists during page isolation Message-ID: <20201005140531.GE4555@dhcp22.suse.cz> References: <20200922143712.12048-1-vbabka@suse.cz> <20200922143712.12048-10-vbabka@suse.cz> <10cdae53-c64b-e371-1b83-01d1af7a131e@redhat.com> <2ce92f9a-eaa2-45b2-207c-46a79d6a2bde@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2ce92f9a-eaa2-45b2-207c-46a79d6a2bde@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Fri 25-09-20 13:10:05, Vlastimil Babka wrote: > On 9/25/20 12:54 PM, David Hildenbrand wrote: > >>> --- a/mm/page_isolation.c > >>> +++ b/mm/page_isolation.c > >>> @@ -15,6 +15,22 @@ > >>> #define CREATE_TRACE_POINTS > >>> #include > >>> > >>> +void zone_pcplist_disable(struct zone *zone) > >>> +{ > >>> + down_read(&pcp_batch_high_lock); > >>> + if (atomic_inc_return(&zone->pcplist_disabled) == 1) { > >>> + zone_update_pageset_high_and_batch(zone, 0, 1); > >>> + __drain_all_pages(zone, true); > >>> + } > >> Hm, if one CPU is still inside the if-clause, the other one would > >> continue, however pcp wpould not be disabled and zones not drained when > >> returning. > > Ah, well spotted, thanks! > > >> (while we only allow a single Offline_pages() call, it will be different > >> when we use the function in other context - especially, > >> alloc_contig_range() for some users) > >> > >> Can't we use down_write() here? So it's serialized and everybody has to > >> properly wait. (and we would not have to rely on an atomic_t) > > Sorry, I meant down_write only temporarily in this code path. Not > > keeping it locked in write when returning (I remember there is a way to > > downgrade). > > Hmm that temporary write lock would still block new callers until previous > finish with the downgraded-to-read lock. > > But I guess something like this would work: > > retry: > if (atomic_read(...) == 0) { > // zone_update... + drain > atomic_inc(...); > else if (atomic_inc_return == 1) > // atomic_cmpxchg from 0 to 1; if that fails, goto retry > > Tricky, but races could only read to unnecessary duplicated updates + flushing > but nothing worse? > > Or add another spinlock to cover this part instead of the temp write lock... Do you plan to post a new version or should I review this one? -- Michal Hocko SUSE Labs