Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1168632rwb; Fri, 13 Jan 2023 08:43:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXsN5ELpJYa9PCX3YJcQwKh2IV/TiwqzZRezXgVG+pxE14ImvDpHTczu7IQdftXWq2l8kzLl X-Received: by 2002:a17:907:d306:b0:84c:95c7:3036 with SMTP id vg6-20020a170907d30600b0084c95c73036mr47715686ejc.5.1673628215080; Fri, 13 Jan 2023 08:43:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673628215; cv=none; d=google.com; s=arc-20160816; b=VkxLvn+wQXtfUNNyOk+v0pqqmrp9uAMQj74MKSFsKWCnz1zuJjOprUdLPYbcRKvdgA Houb33OP91gSPEU1aVAOkTWLbMvRh5h5X4U3AtDC+HCXSG+W+7jkmL0pwI/zjPb6VPpP yUbMLEBGZ0QvnA37zZLiVK3ytMB/FsQiarBZJuPh55X1CN+FIGpuQoTSpWENLvhmaQf7 fT+iNlxas9KKFqEq+FHKiNkt5RCklbTxdw88YrErtA/D42qoaCeo/TZezl8Tc0MOMhXV YwBpL9Fgt/pch1tC1Wmrb+XirQvnYugHcrHg5e8ATu5HpqDlVU76i0pHI5dqMGC7Br30 Bt8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zFYXeQHB5mBEYDHWaUYTs7tQmOKRVt8dzinfneBzAwA=; b=fBhUpm6FdEqYvyDP6fcSZ6gA4UCcZpEzX2J0M3DRNNjzj5h6b+WDiVVQONjNkECmc+ qQxc814lJpOyC3R5allSq8z6mrKKZJO1JUcRD8jvta2OQOkF28GwlZ25XnYwQiG2/DGs qSp1IH2xrd5qxKoIZFY1S38gh4EBefzlvrbsTxNaJFwhZP5CiNEK7E326GOMEQGWS5KZ wUAkHlUOabPzC/obUnO07ZkSy24KcWfPO6AC2bpsoX05Fn/aSBcuVZvWyt7ZL6at4hQy Sl7dd9G+U6mx8Bb3pEkgjyaifMWD5Nc/jKX+klXE+oRPIBcwiLT/IdFkxMqA806GKgNI ACPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="aFZyL6L/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb34-20020a1709071ca200b0085b87a8f80csi10585185ejc.207.2023.01.13.08.43.22; Fri, 13 Jan 2023 08:43:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="aFZyL6L/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbjAMQ3F (ORCPT + 53 others); Fri, 13 Jan 2023 11:29:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjAMQ2Q (ORCPT ); Fri, 13 Jan 2023 11:28:16 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E91897ECA5; Fri, 13 Jan 2023 08:22:44 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 823AB6BBA9; Fri, 13 Jan 2023 16:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1673626963; h=from:from:reply-to: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=zFYXeQHB5mBEYDHWaUYTs7tQmOKRVt8dzinfneBzAwA=; b=aFZyL6L/H2u/JrlrEmotKR4SoE/eWsdutW6toqBDqmxlhbK/ZONAYVU75Hapted0dAHIjZ nC3D92R6XNevYUZ0CCPedkqLxpwyZUGsLE+8F+RSFgxhbb1mJMr7jqssSK33WljMceFiJs 1H+u3To0piVwyxUxd4Yn14wXQyBejX4= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 64D2A1358A; Fri, 13 Jan 2023 16:22:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UAAyFlOFwWOkUwAAMHmgww (envelope-from ); Fri, 13 Jan 2023 16:22:43 +0000 Date: Fri, 13 Jan 2023 17:22:42 +0100 From: Michal Hocko To: Zhongkun He Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, wuyun.abel@bytedance.com Subject: Re: [PATCH 0/3] mm: replace atomic_t with percpu_ref in mempolicy. Message-ID: References: <20221204161432.2149375-1-hezhongkun.hzk@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 13-01-23 17:20:39, Michal Hocko wrote: > On Mon 05-12-22 00:14:29, Zhongkun He wrote: > > All vma manipulation is somewhat protected by a down_read on > > mmap_lock, so vma mempolicy is clear to obtain a reference. > > But there is no locking in process context and have a mix > > of reference counting and per-task requirements which is rather > > subtle and easy to get wrong. > > > > we would have get_vma_policy() always returning a reference > > counted policy, except for static policy. For better performance, > > we replace atomic_t ref with percpu_ref in mempolicy, which is > > usually the performance bottleneck in hot path. > > > > This series adjust the reference of mempolicy in process context, > > which will be protected by RCU in read hot path. Besides, > > task->mempolicy is also protected by task_lock(). Percpu_ref > > is a good way to reduce cache line bouncing. > > > > The mpol_get/put() can just increment or decrement the local > > counter. Mpol_kill() must be called to initiate the destruction > > of mempolicy. A mempolicy will be freed when the mpol_kill() > > is called and the reference count decrese to zero. > > This is really hard to follow. Without having the context from previous > discussions I would be completely lost. Please structure your cover > letter but also other patch in general in the form: > - what is the problem you would like to deal with > - want to introduce pidfd_set_mempolicy because XYZ > - what stands in the way > - mempolicy objects access constrains (reliance on operating in > the current context) > - reference counting needs to be unconditional > - why regular reference counting is not sufficient (performance) > - what is this patchset proposing > - per cpu reference counting > - how is it implemented > - how is the patch series structured > - make the reference counting unconditional > - special case static (never released) policies > - replace standard ref counting by per-cpu reference counting - introduce pidfd_set_mempolicy > - how has this been tested? -- Michal Hocko SUSE Labs