From patchwork Thu May 21 13:34:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 6455301 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A99279F1CC for ; Thu, 21 May 2015 13:36:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3D36204A2 for ; Thu, 21 May 2015 13:35:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A7D52046F for ; Thu, 21 May 2015 13:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756081AbbEUNfv (ORCPT ); Thu, 21 May 2015 09:35:51 -0400 Received: from m59-178.qiye.163.com ([123.58.178.59]:58879 "EHLO m59-178.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755928AbbEUNfs (ORCPT ); Thu, 21 May 2015 09:35:48 -0400 Received: from localhost.localdomain (unknown [113.240.220.93]) by m59-178.qiye.163.com (HMail) with ESMTPA id 3A7C71480B76; Thu, 21 May 2015 21:35:43 +0800 (CST) From: Li Wang To: Sage Weil Cc: ceph-devel@vger.kernel.org, MingXin Liu Subject: [PATCH 3/5] Osd: add a temperature based object eviction policy for cache tiering Date: Thu, 21 May 2015 21:34:08 +0800 Message-Id: <385339e04bb5fedc4758c67d5547730d61362586.1432214851.git.liwang@ubuntukylin.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUlLVU1OQkJCQkNPTE9KSUpKV1kJDhceCFlBWS grPSQoND0vPToyNyQyNSQzPjo*PilBS1VLQDYjJCI#KCQyNSQzPjo*PilBS1VLQCsvKSQ1NCQyNS QzPjo*PilBSVVLQD8iNTo2MjgkMiskNTQkMjUkMz46Pz4pQUtVS0A2LjcvMiQpOCsvJD8yPT0#KT 41LyQyNSQzPjo*PilBSVVLQDIrJC80PzoiJDg1LyRLJEpLS0FLVUtAMiskSiQzNC4pJDg1LyRLJE pLS0FLVUtAMiskSiQ2MjUuLz4kODUvJEskSktBS1VLQDIrJEhLJDYyNS4vPiQ4NS8kSyROS0FLVU tAMiskTiQ2MjUuLz4kODUvJEskSktBS1VLQCguOTE#OC8kLzQ*OiIkODUvJEskSktLQUtVS0AoLj kxPjgvJE4kNjI1Li8#JDg1LyRLJEpLQUtVS0AoLjkxPjgvJEokMzQuKSQ4NS8kSyRKS0tBS1VLQD U0LyQ9OjY0LigkPzQ2OjI1JCgrPSQ9OjI3QUpLVUtAKC45JD5BSlVOTkA9NSQoLjkkPjUsNCk*KC QzNzEkSktLSUtKQUtVSUNAPTUkLik3MjU9NCQzNzEkS0xLTktNQU9VQ0hZBg++ X-HM-Sender-Digest: e1kSHx4VD1lBWUc6ODI6Eww4DDo8MAFWUS8KNDAWEAswCiNVSlVKT0hJ SUpOSE9PT05IVTMWGhIXVRcSDBoVHDsOGQ4VDw4QAhcSFVUYFBZFWVdZDB4ZWUEdGhcIHldZCAFZ QU1ISk03V1kSC1lBWUpKSFVJT0tVSUlLVUJIWQY+ X-HM-Tid: 0a4d76afd0cc649f3a7c71480b76 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: MingXin Liu Signed-off-by: MingXin Liu Reviewed-by: Li Wang --- src/osd/ReplicatedPG.cc | 110 +++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 52 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 4c549a5..b2d49c6 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -10822,44 +10822,45 @@ bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) } } + int atime = -1, temp = 0; + uint64_t atime_upper = 0, atime_lower = 0; + uint64_t temp_upper = 0, temp_lower = 0; + if (agent_state->evict_mode != TierAgentState::EVICT_MODE_FULL) { // is this object old and/or cold enough? - int atime = -1, temp = 0; - if (hit_set) - agent_estimate_atime_temp(soid, &atime, NULL /*FIXME &temp*/); - - uint64_t atime_upper = 0, atime_lower = 0; - if (atime < 0 && obc->obs.oi.mtime != utime_t()) { - if (obc->obs.oi.local_mtime != utime_t()) { - atime = ceph_clock_now(NULL).sec() - obc->obs.oi.local_mtime; - } else { - atime = ceph_clock_now(NULL).sec() - obc->obs.oi.mtime; + if (pool.info.cache_measure == pg_pool_t::CACHEMEASURE_ATIME) { + agent_estimate_atime_temp(soid, &atime, NULL); + + if (atime < 0 && obc->obs.oi.mtime != utime_t()) { + if (obc->obs.oi.local_mtime != utime_t()) { + atime = ceph_clock_now(NULL).sec() - obc->obs.oi.local_mtime; + } else { + atime = ceph_clock_now(NULL).sec() - obc->obs.oi.mtime; + } } - } - if (atime < 0) { - if (hit_set) { - atime = pool.info.hit_set_period * pool.info.hit_set_count; // "infinite" - } else { - atime_upper = 1000000; + if (atime < 0) { + if (hit_set) { + atime = pool.info.hit_set_period * pool.info.hit_set_count; // "infinite" + } else { + atime_upper = 1000000; + } } - } - if (atime >= 0) { - agent_state->atime_hist.add(atime); - agent_state->atime_hist.get_position_micro(atime, &atime_lower, + if (atime >= 0) { + agent_state->atime_hist.add(atime); + agent_state->atime_hist.get_position_micro(atime, &atime_lower, &atime_upper); - } + } + } else { + agent_estimate_atime_temp(soid, NULL, &temp); - unsigned temp_upper = 0, temp_lower = 0; - /* - // FIXME: bound atime based on creation time? - agent_state->temp_hist.add(atime); - agent_state->temp_hist.get_position_micro(temp, &temp_lower, &temp_upper); - */ + agent_state->temp_hist.add(temp); + agent_state->temp_hist.get_position_micro(temp, &temp_lower, &temp_upper); + } dout(20) << __func__ - << " atime " << atime + << " atime " << atime << " pos " << atime_lower << "-" << atime_upper - << ", temp " << temp + <<" temp " << temp << " pos " << temp_lower << "-" << temp_upper << ", evict_effort " << agent_state->evict_effort << dendl; @@ -10872,9 +10873,10 @@ bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) delete f; *_dout << dendl; - // FIXME: ignore temperature for now. - - if (1000000 - atime_upper >= agent_state->evict_effort) + if (pool.info.cache_measure == pg_pool_t::CACHEMEASURE_ATIME) { + if(1000000 - atime_upper >= agent_state->evict_effort) + return false; + } else if (temp_lower >= agent_state->evict_effort) return false; } @@ -11124,29 +11126,33 @@ void ReplicatedPG::agent_estimate_atime_temp(const hobject_t& oid, int *atime, int *temp) { assert(hit_set); - *atime = -1; - if (temp) - *temp = 0; - if (hit_set->contains(oid)) { - *atime = 0; - if (temp) - ++(*temp); - else + if (atime) { + *atime = -1; + if (hit_set->contains(oid)) { + *atime = 0; return; - } - time_t now = ceph_clock_now(NULL).sec(); - for (map::reverse_iterator p = - agent_state->hit_set_map.rbegin(); - p != agent_state->hit_set_map.rend(); - ++p) { - if (p->second->contains(oid)) { - if (*atime < 0) - *atime = now - p->first; - if (temp) - ++(*temp); - else + } + time_t now = ceph_clock_now(NULL).sec(); + for (map::reverse_iterator p = + agent_state->hit_set_map.rbegin(); + p != agent_state->hit_set_map.rend(); ++p) { + if (p->second->contains(oid)) + *atime = now - p->first; + if (*atime >= 0) return; } + } else if (temp) { + *temp = 0; + unsigned i = 0; + if (hit_set->contains(oid)) + *temp += pool.info.get_grade(0); + for (map::reverse_iterator p = + agent_state->hit_set_map.rbegin(); + p != agent_state->hit_set_map.rend(); ++p) { + ++i; + if (p->second->contains(oid)) + *temp += pool.info.get_grade(i); + } } }