Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp755911rwi; Thu, 13 Oct 2022 05:01:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4reQiWxo4mfsMXsRskFE2P6/I2dpZCmkCAZXQyyxWHrizYdBtsVf1ZwDGnWWcTnRXNpORb X-Received: by 2002:a17:90b:1e0b:b0:20d:7ddf:9b08 with SMTP id pg11-20020a17090b1e0b00b0020d7ddf9b08mr10797557pjb.187.1665662501339; Thu, 13 Oct 2022 05:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665662501; cv=none; d=google.com; s=arc-20160816; b=MaR0DiaxbjdiRemRBFy6isFi6WiuRI6uyd6IlB8g+XnhIy4hIZl1DmgqGHRB26GRvh KpI9cJrlSrPO4Z2BhQEFwWOPS1rMnx8WaP7JDAKIJ2dybwq+MJd1lLEBXH0MU2aQ4a2z Rfd/iWX66F2PsYcvMTjY2CsFyNzdAjEQFKWJh5adxGyobHyKrJlJ2E1BXMZ9Mg1J3DT8 /Ppp5LR3yhZ/9zrneew+pUYIWLwhfVubkZiuu6yVntMFAKIIBWo8MDQ2xW46tfHVzmAD 2iGF/G738M6nZfWngcU0VgLyGsYkFNQuKnoIRlYRkSBRf2EXLb5FUDjkp24dfDW7tprp 1fdg== 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=rPzh/va1HT0bek5swCb3HGwjBRkzj98iREmCtc7/+jo=; b=L2x3JHwSXr9r3F8FAlH7HyiYfQmo2RVDaWl/kr6w02Y2BR02a/uqOMzG02vuntEs6t yymrqaUr8cnixqDv9YYANaSVYZjDPQ2f/ry7xBhOhA82msny5P72M8soDGAQYTFtpOvr B2JQnjPGpXjuUaTn3jB8oINHjVd/iynObLhaKhQ5HSeA2CQW0H+hdBCetwES2wo81IXP YuolXML1+7InG4NTj+lhKdGYh4bSVxymZhsnSXom38g+tEHmyBc4NG4aaRLHUxhZ0OUi JXAxAEfPwjmCkJTK9UCk8U9xxw38LnSt/9z12Or/tNrftVKGwjdhWi2yQKgAZeJL+u4o CiDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=kXtgnuQJ; 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 i10-20020a170902cf0a00b00172db9d9a01si22083852plg.616.2022.10.13.05.01.28; Thu, 13 Oct 2022 05:01:41 -0700 (PDT) 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=kXtgnuQJ; 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 S229715AbiJML0o (ORCPT + 99 others); Thu, 13 Oct 2022 07:26:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbiJML0m (ORCPT ); Thu, 13 Oct 2022 07:26:42 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 208F63C8FC; Thu, 13 Oct 2022 04:26:40 -0700 (PDT) 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 86F0421AEE; Thu, 13 Oct 2022 11:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1665660399; 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=rPzh/va1HT0bek5swCb3HGwjBRkzj98iREmCtc7/+jo=; b=kXtgnuQJJGWDKwso+qTh/xvZDwLbG3+HBKwfuMeuMVmVAKQwsJmynGOl2z4JLOiFmVLnsj M0fTKq2QnyO7yBec9P+hxdUPVXWAb5aIPMI87DERWNI551oQRlr6ZdTojLt/+LG4AyBQgn D5hQYxLDhRiIoVjWlOqFN4f5TyBjB7c= 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 5688413AAA; Thu, 13 Oct 2022 11:26:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GDi/Ee/1R2OMXgAAMHmgww (envelope-from ); Thu, 13 Oct 2022 11:26:39 +0000 Date: Thu, 13 Oct 2022 13:26:38 +0200 From: Michal Hocko To: Zhongkun He Cc: corbet@lwn.net, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, wuyun.abel@bytedance.com Subject: Re: [External] Re: [RFC] mm: add new syscall pidfd_set_mempolicy() Message-ID: References: <20221010094842.4123037-1-hezhongkun.hzk@bytedance.com> <582cf257-bc0d-c96e-e72e-9164cff4fce1@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 Thu 13-10-22 18:44:55, Zhongkun He wrote: > > On Wed 12-10-22 19:22:21, Zhongkun He wrote: > > > > > > > > Yes, this will require some refactoring and one potential way is to make > > > > mpol ref counting unconditional. The conditional ref. counting has > > > > already caused issues in the past and the code is rather hard to follow > > > > anyway. I am not really sure this optimization is worth it. > > > > > > > > Another option would be to block the pidfd side of things on completion > > > > which would wake it up from the task_work context but I would rather > > > > explore the ref counting approach first and only if this is proven to be > > > > too expensive to go with hacks like this. > > > > > > Hi Michal > > > > > > The counting approach means executing mpol_get/put() when start/finish using > > > mempolicy,right? > > > > We already do that via mpol_{get,put} but there are cases where the > > reference counting is ignored because it cannot be freed and also mpol_cond_put > > resp. open coded versions of mpol_needs_cond_ref. > > Hi Michal > > Could we try to change the MPOL_F_SHARED flag to MPOL_F_STATIC to > mark static mempolicy which cannot be freed, and mpol_needs_cond_ref > can use MPOL_F_STATIC to avoid freeing the static mempolicy. Wouldn't it make more sense to get rid of a different treatment and treat all memory policies the same way? -- Michal Hocko SUSE Labs