Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4455182rwb; Mon, 21 Nov 2022 07:48:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dwUNs7+0V2Y6o8T11D++M0r9bhzEaxec8Jjttvyfkv9TbJ2TxsMJ17gsBP2InociS8N27 X-Received: by 2002:a17:906:4cc1:b0:7ae:50c6:fd0a with SMTP id q1-20020a1709064cc100b007ae50c6fd0amr15665530ejt.184.1669045725649; Mon, 21 Nov 2022 07:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669045725; cv=none; d=google.com; s=arc-20160816; b=pIopMREbPdWcCbicNyrAT1NjABapOQkqV/GevuLGhOIuXRpHUkNVsIr1uEra2HnUWe QL1y5uwZ9V+EHXaNaT8qtixVQjBy9bPUu53/jjFhqXcbAJpV0VnM/G7tieNYMC46WGEY ViqCTB1d4tVC2dFmriVh8LgZQW7y8mj7QR3OVrc3714CaWNUWvqjjSKs74yzu9K19/AD keAMT4z1ulpUZe77ZAwP/M9IS41OYKxZ5y/nOv5jeXRK9HjOwYp8Gu24YmpOrMQsaraa NfjQK+1sgJBd1Pcu05pYfGTCVi13Hp/DAZoNZnwQdojGW5kvE8mSVqqjXC7EJJpQd/Uq 74Sg== 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=mGOXq9FRamV9l5/TyyRIyRTXW3ke43JzevqLuofDH3Y=; b=Hnwd5f8A25Ht9r5bfiGKF4CChQhxw+yJ3hLPRN7r0IBrBXtQVL9M5SMRnAchXHk9rg B0eqMqrknVdC/0zcIOORXnG4qQk91NEeBlffFw2bQMnup2SgPO9ynVMSmBq4mqeUScdH eo+4k9AS+kh0rc8oWWLLiyYv70l9tHuUM5Szt0Zci7Dgfdcq88LE8i9I5LHMFOXwjtfm TTT6VC5kXz+vWFzD1+FLfZ46LY8XYdpz66Yh8Xgm2XpkaZA3XVPxmRVoCm7KwkTTM9Y4 vqfpvcJRUydXiW7DKyBz+8SfTwpwHjeldK8EIPCs79r1fDo1iap6eVw1hSLbkyNnTIz6 cOhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Qp2QXy9N; 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 wy4-20020a170906fe0400b0078cc8a2cf4bsi9826261ejb.614.2022.11.21.07.48.13; Mon, 21 Nov 2022 07:48:45 -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=Qp2QXy9N; 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 S231672AbiKUOlD (ORCPT + 91 others); Mon, 21 Nov 2022 09:41:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbiKUOiw (ORCPT ); Mon, 21 Nov 2022 09:38:52 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 444C3C6607; Mon, 21 Nov 2022 06:38:20 -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 BA05322102; Mon, 21 Nov 2022 14:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1669041498; 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=mGOXq9FRamV9l5/TyyRIyRTXW3ke43JzevqLuofDH3Y=; b=Qp2QXy9NNTrYv3zdpSBl0EZsKd2ZL4OlKqi1kbMro7WI8hKQmgvUkR5L5vMjAFNaRoKLll 28zbJVicyhWSeXLfFhwMz7vyyC3ls5CZwNNI49b0di3gjRKWTlcRmEloPow04B6nT11aGG twcB4xQMvDzPaA2kU7Qi82sGddWVsp4= 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 8B7351377F; Mon, 21 Nov 2022 14:38:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7T40H1qNe2PBIgAAMHmgww (envelope-from ); Mon, 21 Nov 2022 14:38:18 +0000 Date: Mon, 21 Nov 2022 15:38:17 +0100 From: Michal Hocko To: Zhongkun He Cc: Andrew Morton , corbet@lwn.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [External] Re: [PATCH v2] mm: add new syscall pidfd_set_mempolicy(). Message-ID: References: <20221111084051.2121029-1-hezhongkun.hzk@bytedance.com> <20221111112732.30e1696bcd0d5b711c188a9a@linux-foundation.org> <3a3b4f5b-14d1-27d8-7727-cf23da90988f@bytedance.com> <82c9c89c-aee2-08a3-e562-359631bb0137@bytedance.com> <0bd0b744-3d97-b4c3-a4fb-6040f8f8024a@bytedance.com> <6433156f-34a8-400f-e282-91268b242279@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6433156f-34a8-400f-e282-91268b242279@bytedance.com> 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 17-11-22 15:19:20, Zhongkun He wrote: > Hi Michal, thanks for your replay. > > > > > It would be better to add the patch that has been tested. > > OK. > > > > > One way to deal with that would be to use a similar model as css_tryget > > Percpu_ref is a good way to reduce memory footprint in fast path.But it > has the potential to make mempolicy heavy. the sizeof mempolicy is 32 > bytes and it may not have a long life time, which duplicated from the > parent in fork().If we modify atomic_t to percpu_ref, the efficiency of > reading in fastpath will increase, the efficiency of creation and > deletion will decrease, and the occupied space will increase > significantly.I am not really sure it is worth it. > > atomic_t; 4 > sizeof(percpu_ref + percpu_ref_data + cpus* unsigned long) > 16+56+cpus*8 Yes the memory consumption is going to increase but the question is whether this is something that is a real problem. Is it really common to have many vmas with a dedicated policy? What I am arguing here is that there are essentially 2 ways forward. Either we continue to build up on top of the existing and arguably very fragile code and make it even more subtle or follow a general pattern of a proper reference counting (with usual tricks to reduce cache line bouncing and similar issues). I do not really see why memory policies should be any different and require very special treatment. > > Btw. have you tried to profile those slowdowns to identify hotspots? > > > > Thanks > > Yes, it will degrade performance about 2%-%3 may because of the task_lock > and atomic operations on the reference count as shown > in the previous email. > > new hotspots in perf. > 1.34% [kernel] [k] __mpol_put > 0.53% [kernel] [k] _raw_spin_lock > 0.44% [kernel] [k] get_task_policy Thanks! -- Michal Hocko SUSE Labs