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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 517CFC54EBD for ; Fri, 13 Jan 2023 16:22:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5BE68E0002; Fri, 13 Jan 2023 11:22:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D0BF18E0001; Fri, 13 Jan 2023 11:22:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD3F58E0002; Fri, 13 Jan 2023 11:22:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AA3018E0001 for ; Fri, 13 Jan 2023 11:22:46 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6E5AC1208FB for ; Fri, 13 Jan 2023 16:22:46 +0000 (UTC) X-FDA: 80350294332.22.FE43F2B Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf12.hostedemail.com (Postfix) with ESMTP id C3AC24001B for ; Fri, 13 Jan 2023 16:22:44 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="aFZyL6L/"; spf=pass (imf12.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673626964; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zFYXeQHB5mBEYDHWaUYTs7tQmOKRVt8dzinfneBzAwA=; b=ENmaEcrUfPF/5IlzY9JvQ60n0oNiOsChx/edPG+hB7BmJV29SgCExQzyssZQiDfVVUk4ni xWgxJZy1vTDCX2GKUpgXV0t6xllHjxhWcjSD0r6CNqKVsbudylu7JcMTAkFnkJbsArkjjW EApm0ygwoCXmJl6oij2QqX34GYR9KBQ= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="aFZyL6L/"; spf=pass (imf12.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673626965; a=rsa-sha256; cv=none; b=FqjRXvaxZEPmpWscEy5AaNed24S1fz4YBPfy5J9W3fKxlMw7ibt6CE1vS99HdHaDNX6UhF YwyyGjujx++pAzeVv6GhB6DGmfZPf5Q++6yiuCb+FVmbijZSvxiPe4wiKRD5PpSpb3N8/2 ojuqu81Yd2wqwwmhPEGbSaKKap4me8w= 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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C3AC24001B X-Stat-Signature: zkqo4rdezuobpaxc5oi1jnxgjeq96i1w X-HE-Tag: 1673626964-511465 X-HE-Meta: U2FsdGVkX18ixdknIT4cgdPjWPBDxQu6dBPVIcNaA1xI5CZLOIHttRf5TZtI2rQ9k/ERGasfRI/JdXwJWWWz6YltAjIbPc8rRhkkgHNC3MetuJd8x/3U3EChSs1ME2JMJ3ezni1SjzFaUS/60/vE2FFb5Xs1IKfhGZ9q0ZzFQxXmDA16bPCKxSlkyj80HrIR6q0pS1ljCGgW2ar+70UJzzJlJqX9vydekwfFZec92emwispZsZUu2sfRmqsCdOM3RgGupUxgHeEnqoSNmzCH/Hm/tT13NklZxZF0tIM0iFc5tZXF5s89XXWdDQjAxNckmtahGmB1oSVScDapmCgXToU77J5s6kFRdpQ/WuBI9UH7LAlFDbiNBahgpGNEqc/XpZ2PvgLxSQCKGkGCQ1z3iabZvr05/BA0eOctF+RfTfgtVAl88TRJGI48H79Bp7Y9CZLdUTC1gHic57XAlnUzkDn2tB6HDJXBouXjgT0sw26VaXpYTWr3Qvucmq82VRUgUuta2Zc5S+IJ8sx9NxZcu4Ef0+/nKA3PuMO7uN9SrvFIH0eNaygzmi9IonqyzmNTyNBMm8BZeTzDAgjL2LOQBZXn1i29a5gXag6ynY7cOCmlraLJjsEBXLZSTUPQ/02LCwDdvX0NRxtor5FBAmMZOuuwmVqtlsWteOa+bK4WKC/Wt1sg+dai/hDA3y7m3OAxSKy5L+c+kdxTZEEvl546IBv9dJTADRSoedd2LpNdJT6j0sNp/4DjpdZClKZkSjsfaItkUTrkUd6Qd9CXvKwWY6cmKnkadXR7TQxPklmWFJL4l8vwRLcdBEuOpiiVZZbcZ2qQww9s8Y6M2/R+uSP/+vMmejWAnKO3Tjp1ek8E/jSgcxwzEThPIiUxQhVA7xpC54fajEjyBesaQZe6fa0MWVl1h5/TXVm4 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 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