Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3671263rwi; Wed, 12 Oct 2022 05:26:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68Fsu1Qax1ockwfxjc3JmQtHyb771FKMn12Wku5LGhYsA/KPG6Z3rvxQCyyqJdL4jAw6Tf X-Received: by 2002:a17:902:7481:b0:180:fde5:98a8 with SMTP id h1-20020a170902748100b00180fde598a8mr22687281pll.81.1665577573808; Wed, 12 Oct 2022 05:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665577573; cv=none; d=google.com; s=arc-20160816; b=dsdHvMxcQFChulZDWPXYrQ8NUxCXGkJ3K5mGX9vQ5jMPaCT9V8aU/X25hUZHdbjp/C wdyeWQdSYA+ylJzcNpBrOVTb9NqW232m8YfPhvorx4X0rQERFq4cti2pc/zZO5Tdfsbz xCxrYVF13PeIQ7aFXtQKmCUjXwoAdLkJIKj4npYjghoifPa/9kHqVlGnIMh4NWfkLk+o YbXYbtrGZqZNkpNIEonTKpHOb8+3KRyXF+QPxo0BEiH3rTa20ENRU5xd0jJsaG70/Kh4 jCNgSxRiW/KOXH1nr5jc+1HAuBwWeKASm8O3B7ZmYwTOXBnqs6I675GC4JphD/Dcj1v4 tMOg== 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=dCQ2WpDCxrbeT5GJTKPF0LqosNd9RnwLmJ2qJ7436Gs=; b=ZyxCkN/pukQ25yvaYtbD9xM4uiAR87oJZBlMVodXFUpqcFlkHsNHSPrjOlrmP6w4s7 2AB/CWDgjjz2g4IeemT+CuVO0etlep6jka4qbS1jAYRTQwhPTMxQ0fTbmg/gOUK90dk+ 6JehEXabrZDjtGrgeD+AEQTOQRjfPHj6DnEHP1nE5mWUmvnsvTIbtWFh85dHZ9U++IIg z2MnQpp6kLBTSYgA5aqBnfn9SbWBh+SAzQj5DyfdUYPwpZlMUzpqnaHPGyjVnNhekQyh k4bEGCA9FT+z8eZR+fGq8mY7J+f6oyxCC8FlM8t6aU1FQRgHfgIhbHvDEW8U98IejG44 Dgjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="K/Ilkhgr"; 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 e3-20020a170902744300b0017f733f414asi16645471plt.240.2022.10.12.05.26.00; Wed, 12 Oct 2022 05:26:13 -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="K/Ilkhgr"; 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 S229790AbiJLMPR (ORCPT + 99 others); Wed, 12 Oct 2022 08:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbiJLMPO (ORCPT ); Wed, 12 Oct 2022 08:15:14 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDCB543607; Wed, 12 Oct 2022 05:15:12 -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 6069C21BF9; Wed, 12 Oct 2022 12:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1665576911; 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=dCQ2WpDCxrbeT5GJTKPF0LqosNd9RnwLmJ2qJ7436Gs=; b=K/IlkhgrX+2welPakjC0Axi79t2kTcd8AbUB/YTbrcVymSQOLha6U/tbxVDRKT4KIKkyAZ 7Sy+HUDJFDfhIl82HhHEsetW0xrPGq6muCTweAJz5vkYuZvsAKtGgGbGBpLJ0vamfcQ6gE 79FoAkuLBJcGOH2Op8WMHHngsqv5zn4= 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 21B9313A5C; Wed, 12 Oct 2022 12:15:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id n/pZB8+vRmM4UgAAMHmgww (envelope-from ); Wed, 12 Oct 2022 12:15:11 +0000 Date: Wed, 12 Oct 2022 14:15:10 +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 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. -- Michal Hocko SUSE Labs